Skip to content

Commit

Permalink
Merge pull request #433 from R-Sourabh/update-product-identifiers-fix
Browse files Browse the repository at this point in the history
Fixed: Allowed users to successfully update product identifiers(#430)
  • Loading branch information
ymaheshwari1 authored Feb 3, 2025
2 parents e79169f + bab2ce8 commit e9e4715
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ const actions: ActionTree<UserState, RootState> = {
return uniqueFacilities
}, []);

const currentFacility: any = getCurrentFacilityId();
const currentEComStore = await UserService.getEComStores(token, currentFacility?.facilityId);
const currentFacilityId: any = getCurrentFacilityId();
const currentEComStore = await UserService.getEComStores(token, currentFacilityId);
useUserStore().currentEComStore = currentEComStore
const productStoreId = currentEComStore?.productStoreId;

await useProductIdentificationStore().getIdentificationPref(productStoreId)
Expand All @@ -90,7 +91,7 @@ const actions: ActionTree<UserState, RootState> = {
commit(types.USER_PERMISSIONS_UPDATED, appPermissions);
commit(types.USER_TOKEN_CHANGED, { newToken: token })
// Get facility location of selected facility
dispatch('getFacilityLocations', currentFacility.facilityId);
dispatch('getFacilityLocations', currentFacilityId);
// TODO: fetch product identifications from enumeration instead of storing it in env
this.dispatch('util/getForceScanSetting', currentEComStore?.productStoreId);
this.dispatch('util/getBarcodeIdentificationPref', currentEComStore?.productStoreId);
Expand Down Expand Up @@ -173,12 +174,16 @@ const actions: ActionTree<UserState, RootState> = {
*/
async setFacility ({ commit, dispatch }, facilityId) {
const token = store.getters['user/getUserToken'];
const previousEComStore = await useUserStore().getCurrentEComStore as any
const eComStore = await UserService.getEComStores(token, facilityId);

commit(types.USER_CURRENT_ECOM_STORE_UPDATED, eComStore);
await dispatch('getFacilityLocations', facilityId)
eComStore?.productStoreId ? this.dispatch('util/getForceScanSetting', eComStore.productStoreId) : this.dispatch('util/updateForceScanStatus', false)
eComStore?.productStoreId ? this.dispatch('util/getBarcodeIdentificationPref', eComStore.productStoreId) : this.dispatch('util/updateBarcodeIdentificationPref', "internalName")

if(previousEComStore.productStoreId !== eComStore.productStoreId) {
await useUserStore().setEComStorePreference(eComStore);
commit(types.USER_CURRENT_ECOM_STORE_UPDATED, eComStore);
eComStore?.productStoreId ? this.dispatch('util/getForceScanSetting', eComStore.productStoreId) : this.dispatch('util/updateForceScanStatus', false)
eComStore?.productStoreId ? this.dispatch('util/getBarcodeIdentificationPref', eComStore.productStoreId) : this.dispatch('util/updateBarcodeIdentificationPref', "internalName")
}
},

/**
Expand Down

0 comments on commit e9e4715

Please sign in to comment.