Skip to content

Commit

Permalink
Improved: logic for flagging error in api calls (#390)
Browse files Browse the repository at this point in the history
  • Loading branch information
amansinghbais committed Oct 11, 2024
1 parent 854bb0a commit efcd53f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/store/modules/shipment/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ const actions: ActionTree<ShipmentState, RootState> = {
}
},
async receiveShipmentItem ({ commit }, payload) {

Check warning on line 105 in src/store/modules/shipment/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'commit' is defined but never used

Check warning on line 105 in src/store/modules/shipment/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'commit' is defined but never used
const responses = [];
let areAllSuccess = true;

for (const item of payload.items) {
if(item.quantityReceived === 0) {
if (!item.locationSeqId) {
console.error("Missing locationSeqId on item");
responses.push(false);
areAllSuccess = false;
continue;
}

Expand All @@ -127,18 +127,16 @@ const actions: ActionTree<ShipmentState, RootState> = {

try {
const resp = await ShipmentService.receiveShipmentItem(params)
if(resp.status === 200 && !hasError(resp)){
responses.push(true)
} else {
if(hasError(resp)){
throw resp.data;
}
}
} catch(error: any) {
responses.push(false)
areAllSuccess = false
}
}
}

return responses;
return areAllSuccess;
},
async receiveShipment ({ dispatch }, payload) {
emitter.emit("presentLoader", {message: 'Receiving inprogress.', backdropDismiss: false});
Expand Down

0 comments on commit efcd53f

Please sign in to comment.