Admin Workflow

This commit is contained in:
Dillon Ngo
2024-12-04 12:17:28 +08:00
parent a24f41e5bd
commit 63d7bb677b
4 changed files with 39 additions and 8 deletions
@@ -91,8 +91,6 @@ class UpdateNextQuestionV1AdminWFLogic extends AbstractControllerLogic
$this->canFetchQuestion->passes();
Log::info('currentQuestion: '. json_encode($currentQuestion));
if ($request->has('answerObj')) {
$answer = $request->answerObj;
$answerNextQuestionNumber = $answer['next_question_number'];
@@ -3,7 +3,7 @@
<div class="col">
<h1 class="m-b-50" :class="{ 'text-success': timer }">{{ formattedTime }}</h1>
<loading-component style="height: 50px; top: 0;" key="1" color="success" v-show="isLoading"></loading-component>
<div class="row" v-if="question" v-show="!isLoading">
<div class="row" v-if="question" v-show="!isLoading && !noMoreWork">
<div class="col">
<div class="row m-b-5 animate__animated animate__fadeInUpBig animate__fast" v-if="error">
@@ -333,7 +333,7 @@
</div>
<!-- QUESTION NAVIGATION -->
<div class="row" v-if="question.question_type !== 0">
<div class="row m-b-10" v-if="question.question_type !== 0">
<div class="col p-r-5">
<button class="btn btn-sm btn-default bg-master-lightest btn-block b-rad-none" :disabled="hidePrevious" @click="formTouched = true; submitForm('previous')">Previous</button>
</div>
@@ -348,6 +348,20 @@
</div>
</div>
</div>
<div class="row" v-if="noMoreWork">
<div class="col">
<div class="row m-b-5 animate__animated animate__fadeInUpBig animate__fast" v-if="error">
<div class="col">
<small class="bold fs-12">{{error}}</small>
</div>
</div>
<div class="row m-b-10">
<div class="col p-l-5">
<button class="btn btn-sm btn-primary btn-block b-rad-none" @click="reloadPage();">Reload Page</button>
</div>
</div>
</div>
</div>
</div>
<!-- Debug box -->
<div class="debug-box" v-if="question">
@@ -383,6 +397,7 @@
stepTime: 0,
interval: 1000,
isFetching: false,
noMoreWork: false,
}
},
validations() {
@@ -513,8 +528,14 @@
}
}
},
errorHandler(error){
this.error = 'We are sorry, something went wrong. Please inform tech team.';
errorHandler(error, statusCode, section){
if(section === 'adminWorkFlowFormGetExternalApiResponse' && statusCode === 404){
this.noMoreWork = true;
this.error = '[' + this.question.question_title + '] All records processed. Please reload page to continue' ;
}
else{
this.error = 'We are sorry, something went wrong. Please inform tech team.';
}
this.isFetching = false;
},
submitForm(direction) {
+1 -1
View File
@@ -37,7 +37,7 @@ export default {
if (!success) {
this.openModal();
errorNotification ? this.$store.dispatch('createNotification', { title: response.title, message: response.message, type: 'error' }) : null;
this.errorHandler(response, statusCode); return;
this.errorHandler(response, statusCode, section); return;
}
successNotification ? this.$store.dispatch('createNotification', { title: response.title, message: response.message, type: 'success' }) : null;
+13 -1
View File
@@ -55,6 +55,10 @@ Route::group(['prefix' => 'admin-work-flow', 'as' => 'admin_work_flow.', 'namesp
->whereNotIn('id', $excludedBookingIds)
->first();
if(!$booking){
return jsonResponse(null, 'No booking found', 404);
}
markedProcessing($booking, '1688_admin_workflow_processing');
return $booking ? jsonResponse([
@@ -89,6 +93,10 @@ Route::group(['prefix' => 'admin-work-flow', 'as' => 'admin_work_flow.', 'namesp
->whereHas('transactions', fn ($query) => $query->where('type', TransactionType::PURCHASE_ORDER)->where('status', '<', ApprovalStatus::APPROVED))
->first();
if(!$booking){
return jsonResponse(null, 'No booking found', 404);
}
markedProcessing($booking, 'approve_po_admin_workflow_processing');
$result = new BookingResource($booking);
@@ -123,6 +131,10 @@ Route::group(['prefix' => 'admin-work-flow', 'as' => 'admin_work_flow.', 'namesp
->whereDoesntHave('transactions', fn ($query) => $query->where('type', TransactionType::PURCHASE_ORDER))
->first();
if(!$booking){
return jsonResponse(null, 'No booking found', 404);
}
markedProcessing($booking, 'fill_po_admin_workflow_processing');
$result = new BookingResource($booking);
@@ -139,7 +151,7 @@ Route::group(['prefix' => 'admin-work-flow', 'as' => 'admin_work_flow.', 'namesp
$booking = Booking::find($bookingId);
if (!$booking) {
return jsonResponse(null, 'No approved booking found', 404);
return jsonResponse(null, 'No booking found', 404);
}
$attributes = $booking->modelAttributes()