diff --git a/src/store/modules/order/actions.ts b/src/store/modules/order/actions.ts index 5474f691..f0436368 100644 --- a/src/store/modules/order/actions.ts +++ b/src/store/modules/order/actions.ts @@ -41,11 +41,13 @@ const actions: ActionTree = { return resp; }, async updateProductCount({ commit, state }, payload ) { - state.current.items.find((item: any) => { - if (item.internalName === payload) { - item.quantityAccepted = item.quantityAccepted + 1; - } - }); + const item = state.current.items.find((item: any) => item.internalName === payload); + if (item) { + item.quantityAccepted = item.quantityAccepted ? parseInt(item.quantityAccepted) + 1 : 1; + } else { + showToast(translate("Product not found")); + } + commit(types.ORDER_CURRENT_UPDATED, state.current ) }, async addOrderItem ({ commit }, payload) { diff --git a/src/store/modules/return/actions.ts b/src/store/modules/return/actions.ts index 0a0df3cf..15e259f6 100644 --- a/src/store/modules/return/actions.ts +++ b/src/store/modules/return/actions.ts @@ -33,11 +33,13 @@ const actions: ActionTree = { return resp; }, async updateReturnProductCount ({ commit, state }, payload) { - await state.current.items.find((item: any) => { - if(item.sku === payload){ - item.quantityAccepted = parseInt(item.quantityAccepted) + 1; - } - }); + const item = state.current.items.find((item: any) => item.sku === payload); + if (item) { + item.quantityAccepted = item.quantityAccepted ? parseInt(item.quantityAccepted) + 1 : 1; + } else { + showToast(translate("Product not found")); + } + commit(types.RETURN_CURRENT_UPDATED, state); }, async setCurrent ({ commit, state }, payload) { diff --git a/src/store/modules/shipment/actions.ts b/src/store/modules/shipment/actions.ts index 0bfa860c..42ba78e7 100644 --- a/src/store/modules/shipment/actions.ts +++ b/src/store/modules/shipment/actions.ts @@ -34,11 +34,13 @@ const actions: ActionTree = { }, async updateShipmentProductCount ({ commit, state }, payload) { - await state.current.items.find((item: any) => { - if(item.sku === payload){ - item.quantityAccepted = parseInt(item.quantityAccepted) + 1; - } - }); + const item = state.current.items.find((item: any) => item.sku === payload); + if (item) { + item.quantityAccepted = item.quantityAccepted ? parseInt(item.quantityAccepted) + 1 : 1; + } else { + showToast(translate("Product not found")); + } + commit(types.SHIPMENT_CURRENT_UPDATED, state); }, async setCurrent ({ commit }, payload) {