Skip to content

Commit

Permalink
Merge pull request #252 from hotwax/#251
Browse files Browse the repository at this point in the history
Improved: Orders rejected in BOPIS app should go to Store Pickup Rejected Queue (#251)
  • Loading branch information
adityasharma7 authored Jul 6, 2023
2 parents d74122d + 838e392 commit 1f77bd2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions src/store/modules/order/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,24 +472,25 @@ const actions: ActionTree<OrderState , RootState> ={
}).catch(err => err);
},

async rejectOrderItems ({ commit }, data) {
async rejectOrderItems ({ commit }, order) {
const payload = {
'orderId': data.orderId
'orderId': order.orderId
}
const responses = [];
const responses = [] as any;

// https://blog.devgenius.io/using-async-await-in-a-foreach-loop-you-cant-c174b31999bd
// The forEach, map, reduce loops are not built to work with asynchronous callback functions.
// It doesn't wait for the promise of an iteration to be resolved before it goes on to the next iteration.
// We could use either the for…of the loop or the for(let i = 0;….)
for (const item of data.parts.items) {
for (const item of order.part.items) {
const params = {
...payload,
'rejectReason': item.reason,
'facilityId': item.facilityId,
'orderItemSeqId': item.orderItemSeqId,
'shipmentMethodTypeId': data.parts.shipmentMethodEnum.shipmentMethodEnumId,
'quantity': parseInt(item.quantity)
'shipmentMethodTypeId': order.part.shipmentMethodEnum.shipmentMethodEnumId,
'quantity': parseInt(item.quantity),
...(order.part.shipmentMethodEnum.shipmentMethodEnumId === "STOREPICKUP" && ({"naFacilityId": "PICKUP_REJECTED"})),
}
const resp = await OrderService.rejectOrderItem({'payload': params});
responses.push(resp);
Expand Down
2 changes: 1 addition & 1 deletion src/views/OrderDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export default defineComponent({
},{
text: this.$t('Reject Order'),
handler: () => {
this.store.dispatch('order/setUnfillableOrderOrItem', { orderId: order.orderId, parts: this.getCurrentOrderPart() }).then((resp) => {
this.store.dispatch('order/setUnfillableOrderOrItem', { orderId: order.orderId, part: this.getCurrentOrderPart() }).then((resp) => {
if (resp) this.router.push('/tabs/orders')
})
},
Expand Down

0 comments on commit 1f77bd2

Please sign in to comment.