From 9431275236005d619d90cfcd3e16193cd59ec037 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Tue, 20 Feb 2024 11:33:12 +0530 Subject: [PATCH 1/6] Fixed: issue in receiving shipment when adding a new item due to missing locationSeqId for that item(#319) --- src/store/modules/shipment/actions.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/store/modules/shipment/actions.ts b/src/store/modules/shipment/actions.ts index cdff8f20..c1bf202e 100644 --- a/src/store/modules/shipment/actions.ts +++ b/src/store/modules/shipment/actions.ts @@ -6,6 +6,7 @@ import * as types from './mutation-types' import { hasError, showToast } from '@/utils' import { translate } from '@hotwax/dxp-components' import emitter from '@/event-bus' +import store from "@/store"; const actions: ActionTree = { async findShipment ({ commit, state }, payload) { @@ -134,7 +135,8 @@ const actions: ActionTree = { const product = { ...item, quantityAccepted: 0, - quantityOrdered: 0 + quantityOrdered: 0, + locationSeqId: store.state.user.facilityLocationsByFacilityId[store.state.user.currentFacility.facilityId]?.[0] ? store.state.user.facilityLocationsByFacilityId[store.state.user.currentFacility.facilityId][0].locationSeqId : '' } const params = { orderId: payload.orderId, From a7730a3039ec905947beeb60a598b8f1d68f4f1f Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Tue, 20 Feb 2024 11:51:53 +0530 Subject: [PATCH 2/6] Improved: logic to handle the case for purchase order as well(#319) --- src/store/modules/shipment/actions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/modules/shipment/actions.ts b/src/store/modules/shipment/actions.ts index c1bf202e..3ae6f078 100644 --- a/src/store/modules/shipment/actions.ts +++ b/src/store/modules/shipment/actions.ts @@ -136,7 +136,7 @@ const actions: ActionTree = { ...item, quantityAccepted: 0, quantityOrdered: 0, - locationSeqId: store.state.user.facilityLocationsByFacilityId[store.state.user.currentFacility.facilityId]?.[0] ? store.state.user.facilityLocationsByFacilityId[store.state.user.currentFacility.facilityId][0].locationSeqId : '' + locationSeqId: item.locationSeqId ? item.locationSeqId : store.state.user.facilityLocationsByFacilityId[store.state.user.currentFacility.facilityId]?.[0] ? store.state.user.facilityLocationsByFacilityId[store.state.user.currentFacility.facilityId][0].locationSeqId : '' } const params = { orderId: payload.orderId, From 9842cd77a24e661587f74d8c3f1d550b45b93357 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Tue, 20 Feb 2024 12:18:08 +0530 Subject: [PATCH 3/6] Improved: logic to add product location when adding an item instead of adding it in actions(#319) --- src/store/modules/shipment/actions.ts | 1 - src/views/AddProductModal.vue | 5 ++++- src/views/AddProductToPOModal.vue | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/store/modules/shipment/actions.ts b/src/store/modules/shipment/actions.ts index 3ae6f078..15c8d1b8 100644 --- a/src/store/modules/shipment/actions.ts +++ b/src/store/modules/shipment/actions.ts @@ -136,7 +136,6 @@ const actions: ActionTree = { ...item, quantityAccepted: 0, quantityOrdered: 0, - locationSeqId: item.locationSeqId ? item.locationSeqId : store.state.user.facilityLocationsByFacilityId[store.state.user.currentFacility.facilityId]?.[0] ? store.state.user.facilityLocationsByFacilityId[store.state.user.currentFacility.facilityId][0].locationSeqId : '' } const params = { orderId: payload.orderId, diff --git a/src/views/AddProductModal.vue b/src/views/AddProductModal.vue index b54c255e..cc60d81c 100644 --- a/src/views/AddProductModal.vue +++ b/src/views/AddProductModal.vue @@ -87,7 +87,9 @@ export default defineComponent({ products: 'product/getProducts', isScrollable: 'product/isScrollable', isProductAvailableInShipment: 'product/isProductAvailableInShipment', - productIdentificationPref: 'user/getProductIdentificationPref' + productIdentificationPref: 'user/getProductIdentificationPref', + currentFacility: 'user/getCurrentFacility', + facilityLocationsByFacilityId: 'user/getFacilityLocationsByFacilityId' }) }, methods: { @@ -115,6 +117,7 @@ export default defineComponent({ }) }, async addtoShipment (product: any) { + product.locationSeqId = this.facilityLocationsByFacilityId(this.currentFacility.facilityId) ? this.facilityLocationsByFacilityId(this.currentFacility.facilityId)[0]?.locationSeqId : '' this.store.dispatch('shipment/addShipmentItem', product) }, closeModal() { diff --git a/src/views/AddProductToPOModal.vue b/src/views/AddProductToPOModal.vue index 57d2f73b..15cdf449 100644 --- a/src/views/AddProductToPOModal.vue +++ b/src/views/AddProductToPOModal.vue @@ -87,7 +87,9 @@ export default defineComponent({ products: 'product/getProducts', isScrollable: 'product/isScrollable', isProductAvailableInOrder: 'order/isProductAvailableInOrder', - productIdentificationPref: 'user/getProductIdentificationPref' + productIdentificationPref: 'user/getProductIdentificationPref', + currentFacility: 'user/getCurrentFacility', + facilityLocationsByFacilityId: 'user/getFacilityLocationsByFacilityId' }) }, methods: { @@ -115,6 +117,7 @@ export default defineComponent({ }) }, async addtoOrder (product: any) { + product.locationSeqId = this.facilityLocationsByFacilityId(this.currentFacility.facilityId) ? this.facilityLocationsByFacilityId(this.currentFacility.facilityId)[0]?.locationSeqId : '' this.store.dispatch('order/addOrderItem', product) }, closeModal() { From b97871cc7463a95e559acc0b682f3bc3be2961e5 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Tue, 20 Feb 2024 12:20:04 +0530 Subject: [PATCH 4/6] Removed: unused import and unwanted change(#319) --- src/store/modules/shipment/actions.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/store/modules/shipment/actions.ts b/src/store/modules/shipment/actions.ts index 15c8d1b8..cdff8f20 100644 --- a/src/store/modules/shipment/actions.ts +++ b/src/store/modules/shipment/actions.ts @@ -6,7 +6,6 @@ import * as types from './mutation-types' import { hasError, showToast } from '@/utils' import { translate } from '@hotwax/dxp-components' import emitter from '@/event-bus' -import store from "@/store"; const actions: ActionTree = { async findShipment ({ commit, state }, payload) { @@ -135,7 +134,7 @@ const actions: ActionTree = { const product = { ...item, quantityAccepted: 0, - quantityOrdered: 0, + quantityOrdered: 0 } const params = { orderId: payload.orderId, From cc37abb4889c6f8b9d713a11c1613be32b24b41f Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Tue, 20 Feb 2024 16:07:06 +0530 Subject: [PATCH 5/6] Improved: logic to display toast when receive shpiment api fails(#319) --- src/locales/en.json | 1 + src/store/modules/shipment/actions.ts | 5 +++++ src/views/ShipmentDetails.vue | 4 +++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/locales/en.json b/src/locales/en.json index 55d072a1..75411afd 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -23,6 +23,7 @@ "External ID": "External ID", "Facility": "Facility", "Location": "Location", + "Failed to receive shipment": "Failed to receive shipment", "Failed to receive some of the items": "Failed to receive some of the items", "Failed to update product identifier preference": "Failed to update product identifier preference", "facility location": "facility location", diff --git a/src/store/modules/shipment/actions.ts b/src/store/modules/shipment/actions.ts index cdff8f20..572b4c6a 100644 --- a/src/store/modules/shipment/actions.ts +++ b/src/store/modules/shipment/actions.ts @@ -93,6 +93,10 @@ const actions: ActionTree = { }, receiveShipmentItem ({ commit }, payload) { return Promise.all(payload.items.map(async (item: any) => { + if(!item.locationSeqId) { + return Promise.reject("Missing locationSeqId on item") + } + const params = { shipmentId: payload.shipmentId, facilityId: this.state.user.currentFacility.facilityId, @@ -125,6 +129,7 @@ const actions: ActionTree = { emitter.emit("dismissLoader"); return resp; }).catch(err => { + emitter.emit("dismissLoader"); console.error(err) return err; }); diff --git a/src/views/ShipmentDetails.vue b/src/views/ShipmentDetails.vue index ae402096..35bc296d 100644 --- a/src/views/ShipmentDetails.vue +++ b/src/views/ShipmentDetails.vue @@ -111,7 +111,7 @@ import { useRouter } from 'vue-router'; import Scanner from "@/components/Scanner.vue"; import LocationPopover from '@/components/LocationPopover.vue' import ImageModal from '@/components/ImageModal.vue'; -import { hasError, productHelpers } from '@/utils' +import { hasError, productHelpers, showToast } from '@/utils' import { Actions, hasPermission } from '@/authorization' export default defineComponent({ @@ -213,6 +213,8 @@ export default defineComponent({ const resp = await this.store.dispatch('shipment/receiveShipment', { items: eligibleItems, shipmentId }) if (resp.status === 200 && !hasError(resp)) { this.router.push('/shipments'); + } else { + showToast(translate("Failed to receive shipment")) } }, isEligibleForReceivingShipment() { From f820bff15a4af7a88991bc1ddfabc2ed3b294d09 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Wed, 21 Feb 2024 15:18:39 +0530 Subject: [PATCH 6/6] Fixed: issue when the action throws an error instantly resulting in loader not being dismissed(#319) --- src/App.vue | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/App.vue b/src/App.vue index 17fefaeb..c69c1636 100644 --- a/src/App.vue +++ b/src/App.vue @@ -61,6 +61,16 @@ export default defineComponent({ if (this.loader) { this.loader.dismiss(); this.loader = null as any; + } else { + // Added this else case as there are some scenarios in which the loader is not created and before that the dismissLoader gets called, resulting in the loader not getting dismissed + // So checking that when the loader is not found then try dismissing the loader again after 3 secs. + // The above case appears when directly hitting the shipment detail page and then the receive shipment api throws error + // TODO: need to find a more better approach to dismiss the loader in such case + setTimeout(() => { + if (this.loader) { + this.dismissLoader(); + } + }, 3000) } }, async unauthorized() {