From c6b9e51007e5bb708d28f28918406df32f7fb62f Mon Sep 17 00:00:00 2001 From: R-Sourabh Date: Tue, 28 Jan 2025 16:28:58 +0530 Subject: [PATCH 1/5] Fixed: On updating the facility, the settings related to the facility are also being updated (#500) --- src/store/modules/user/actions.ts | 2 ++ src/views/Settings.vue | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index 92fe37e4..0ea85205 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -186,6 +186,8 @@ const actions: ActionTree = { const eComStore = await UserService.getCurrentEComStore(token, facilityId); await useUserStore().setEComStorePreference(eComStore); commit(types.USER_CURRENT_ECOM_STORE_UPDATED, eComStore) + //fetching partial order rejection config for BOPIS orders aftering updating facility + await dispatch("getPartialOrderRejectionConfig"); await useProductIdentificationStore().getIdentificationPref(eComStore?.productStoreId) }, /** diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 2305d6c1..86837098 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -291,6 +291,7 @@ export default defineComponent({ async updateFacility(facility: any) { await this.store.dispatch('user/setFacility', facility?.facilityId); await this.store.dispatch('user/fetchNotificationPreferences') + this.getRerouteFulfillmentConfiguration(); }, async timeZoneUpdated(tzId: string) { await this.store.dispatch("user/setUserTimeZone", tzId) @@ -423,9 +424,16 @@ export default defineComponent({ resp.data.docs.map((config: any) => { this.rerouteFulfillmentConfig[rerouteFulfillmentConfigMappingFlipped[config.settingTypeEnumId]] = config; }) + } else { + Object.keys(this.rerouteFulfillmentConfigMapping).map((key) => { + this.rerouteFulfillmentConfig[key] = {}; + }); } } catch(err) { logger.error(err) + Object.keys(this.rerouteFulfillmentConfigMapping).map((key) => { + this.rerouteFulfillmentConfig[key] = {}; + }); } }, async updateRerouteFulfillmentConfiguration(config: any, value: any) { From 37ed1cd04640e2e18b3771c020caf67505824a46 Mon Sep 17 00:00:00 2001 From: R-Sourabh Date: Wed, 29 Jan 2025 18:34:37 +0530 Subject: [PATCH 2/5] Improved: Added Get Available Shipment Methods & BOPIS Product Store Settings on Facility Update (#500) --- src/store/modules/user/actions.ts | 1 + src/views/Settings.vue | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index 0ea85205..8cc29577 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -188,6 +188,7 @@ const actions: ActionTree = { commit(types.USER_CURRENT_ECOM_STORE_UPDATED, eComStore) //fetching partial order rejection config for BOPIS orders aftering updating facility await dispatch("getPartialOrderRejectionConfig"); + await dispatch("fetchBopisProductStoreSettings"); await useProductIdentificationStore().getIdentificationPref(eComStore?.productStoreId) }, /** diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 86837098..73c1826c 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -291,7 +291,10 @@ export default defineComponent({ async updateFacility(facility: any) { await this.store.dispatch('user/setFacility', facility?.facilityId); await this.store.dispatch('user/fetchNotificationPreferences') - this.getRerouteFulfillmentConfiguration(); + if(Object.keys(this.rerouteFulfillmentConfigMapping).length > 0) { + this.getAvailableShipmentMethods(); + this.getRerouteFulfillmentConfiguration(); + } }, async timeZoneUpdated(tzId: string) { await this.store.dispatch("user/setUserTimeZone", tzId) From 8b55adaa016c996297b44687980ff77649165407 Mon Sep 17 00:00:00 2001 From: R-Sourabh Date: Thu, 30 Jan 2025 16:04:14 +0530 Subject: [PATCH 3/5] Improved: Added a check to prevent fetching the re-route config and shipment methods when the store does not change during a facility update(#500) --- src/views/Settings.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 73c1826c..97d50fc0 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -289,9 +289,11 @@ export default defineComponent({ }, methods: { async updateFacility(facility: any) { + const previousStoreId = this.currentEComStore.productStoreId await this.store.dispatch('user/setFacility', facility?.facilityId); await this.store.dispatch('user/fetchNotificationPreferences') - if(Object.keys(this.rerouteFulfillmentConfigMapping).length > 0) { + const currentStoreId = this.currentEComStore.productStoreId + if(Object.keys(this.rerouteFulfillmentConfigMapping).length > 0 && previousStoreId !== currentStoreId) { this.getAvailableShipmentMethods(); this.getRerouteFulfillmentConfiguration(); } From 6d5dcba61c073152be90505b4b011c83582326a0 Mon Sep 17 00:00:00 2001 From: R-Sourabh Date: Mon, 3 Feb 2025 10:45:06 +0530 Subject: [PATCH 4/5] Improved: Added a check to compare eComStore before fetching BOPIS settings.(#500) --- src/store/modules/user/actions.ts | 13 +++++++++---- src/views/Settings.vue | 5 ++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index 8cc29577..4c126b6d 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -183,13 +183,18 @@ const actions: ActionTree = { // clearing the orders state whenever changing the facility dispatch("order/clearOrders", null, {root: true}) dispatch("product/clearProducts", null, {root: true}) + const previousEComStore = await useUserStore().getCurrentEComStore as any + // fetching the eComStore for updated facility const eComStore = await UserService.getCurrentEComStore(token, facilityId); await useUserStore().setEComStorePreference(eComStore); commit(types.USER_CURRENT_ECOM_STORE_UPDATED, eComStore) - //fetching partial order rejection config for BOPIS orders aftering updating facility - await dispatch("getPartialOrderRejectionConfig"); - await dispatch("fetchBopisProductStoreSettings"); - await useProductIdentificationStore().getIdentificationPref(eComStore?.productStoreId) + + if(previousEComStore.productStoreId !== eComStore.productStoreId) { + //fetching partial order rejection config for BOPIS orders aftering updating facility + await dispatch("getPartialOrderRejectionConfig"); + await dispatch("fetchBopisProductStoreSettings"); + await useProductIdentificationStore().getIdentificationPref(eComStore?.productStoreId) + } }, /** * Set User Instance Url diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 97d50fc0..fe5d3b4e 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -289,11 +289,10 @@ export default defineComponent({ }, methods: { async updateFacility(facility: any) { - const previousStoreId = this.currentEComStore.productStoreId + const previousEComStoreId = this.currentEComStore.productStoreId await this.store.dispatch('user/setFacility', facility?.facilityId); await this.store.dispatch('user/fetchNotificationPreferences') - const currentStoreId = this.currentEComStore.productStoreId - if(Object.keys(this.rerouteFulfillmentConfigMapping).length > 0 && previousStoreId !== currentStoreId) { + if(Object.keys(this.rerouteFulfillmentConfigMapping).length > 0 && previousEComStoreId !== this.currentEComStore.productStoreId) { this.getAvailableShipmentMethods(); this.getRerouteFulfillmentConfiguration(); } From 388ccd800141b53f8f0f9a520456462a252ef68b Mon Sep 17 00:00:00 2001 From: R-Sourabh Date: Mon, 3 Feb 2025 11:50:16 +0530 Subject: [PATCH 5/5] Improved: Updated the code to set the eCom preference only when the store changes upon changing the facility (#500) --- src/store/modules/user/actions.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index 4c126b6d..c4a88e27 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -186,10 +186,10 @@ const actions: ActionTree = { const previousEComStore = await useUserStore().getCurrentEComStore as any // fetching the eComStore for updated facility const eComStore = await UserService.getCurrentEComStore(token, facilityId); - await useUserStore().setEComStorePreference(eComStore); - commit(types.USER_CURRENT_ECOM_STORE_UPDATED, eComStore) if(previousEComStore.productStoreId !== eComStore.productStoreId) { + await useUserStore().setEComStorePreference(eComStore); + commit(types.USER_CURRENT_ECOM_STORE_UPDATED, eComStore) //fetching partial order rejection config for BOPIS orders aftering updating facility await dispatch("getPartialOrderRejectionConfig"); await dispatch("fetchBopisProductStoreSettings");