Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: On updating the facility, the settings related to the facility are also being updated (#500) #502

Merged
merged 5 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/**
* Login user and return token
*/
async login ({ commit, dispatch, getters }, payload) {

Check warning on line 36 in src/store/modules/user/actions.ts

View workflow job for this annotation

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

'getters' is defined but never used

Check warning on line 36 in src/store/modules/user/actions.ts

View workflow job for this annotation

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

'getters' is defined but never used
try {
const {token, oms} = payload;
dispatch("setUserInstanceUrl", oms);
Expand Down Expand Up @@ -183,10 +183,18 @@
// 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)
await useProductIdentificationStore().getIdentificationPref(eComStore?.productStoreId)

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");
await useProductIdentificationStore().getIdentificationPref(eComStore?.productStoreId)
}
},
/**
* Set User Instance Url
Expand Down Expand Up @@ -326,7 +334,7 @@
commit(types.USER_ALL_NOTIFICATION_PREFS_UPDATED, allNotificationPrefs)
},

async fetchBopisProductStoreSettings({ commit, dispatch }) {

Check warning on line 337 in src/store/modules/user/actions.ts

View workflow job for this annotation

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

'dispatch' is defined but never used

Check warning on line 337 in src/store/modules/user/actions.ts

View workflow job for this annotation

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

'dispatch' is defined but never used
const productStoreSettings = JSON.parse(process.env.VUE_APP_PRODUCT_STORE_SETTING_ENUMS);
const settingValues = {} as any;

Expand Down Expand Up @@ -360,7 +368,7 @@
commit(types.USER_BOPIS_PRODUCT_STORE_SETTINGS_UPDATED, settingValues)
},

async createProductStoreSetting({ commit }, enumeration) {

Check warning on line 371 in src/store/modules/user/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 371 in src/store/modules/user/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 fromDate = Date.now()

try {
Expand Down Expand Up @@ -392,8 +400,8 @@
return fromDate;
},

async setProductStoreSetting({ commit, dispatch, state }, payload) {

Check warning on line 403 in src/store/modules/user/actions.ts

View workflow job for this annotation

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

'dispatch' is defined but never used

Check warning on line 403 in src/store/modules/user/actions.ts

View workflow job for this annotation

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

'dispatch' is defined but never used
const productStoreSettings = JSON.parse(process.env.VUE_APP_PRODUCT_STORE_SETTING_ENUMS);

Check warning on line 404 in src/store/modules/user/actions.ts

View workflow job for this annotation

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

'productStoreSettings' is assigned a value but never used

Check warning on line 404 in src/store/modules/user/actions.ts

View workflow job for this annotation

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

'productStoreSettings' is assigned a value but never used
let prefValue = state.bopisProductStoreSettings[payload.enumId]
const eComStoreId = this.state.user.currentEComStore.productStoreId;

Expand Down
12 changes: 12 additions & 0 deletions src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,13 @@ export default defineComponent({
},
methods: {
async updateFacility(facility: any) {
const previousEComStoreId = this.currentEComStore.productStoreId
await this.store.dispatch('user/setFacility', facility?.facilityId);
await this.store.dispatch('user/fetchNotificationPreferences')
if(Object.keys(this.rerouteFulfillmentConfigMapping).length > 0 && previousEComStoreId !== this.currentEComStore.productStoreId) {
this.getAvailableShipmentMethods();
this.getRerouteFulfillmentConfiguration();
}
},
async timeZoneUpdated(tzId: string) {
await this.store.dispatch("user/setUserTimeZone", tzId)
Expand Down Expand Up @@ -423,9 +428,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) {
Expand Down
Loading