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

Improved: added support to update productStore after updating the facility(#dxp-288) #859

Merged
merged 1 commit into from
Nov 19, 2024
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
5 changes: 2 additions & 3 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,15 @@ const actions: ActionTree<UserState, RootState> = {
/**
* update current facility information
*/
async setFacility ({ commit, dispatch, state }, payload) {
async setFacility ({ commit, dispatch, state }, facility) {
// On slow api response, setFacility takes long to update facility in state.
// Hence displaying loader to not allowing user to navigate to orders page to avoid wrong results.
emitter.emit('presentLoader', {message: 'Updating facility', backdropDismiss: false})

try {
const token = store.getters['user/getUserToken'];
const userProfile = JSON.parse(JSON.stringify(state.current as any));
userProfile.stores = await UserService.getEComStores(token, payload.facility);
userProfile.stores = await UserService.getEComStores(token, facility);

let preferredStore = userProfile.stores[0];
const preferredStoreId = await UserService.getPreferredStore(token);
Expand All @@ -200,7 +200,6 @@ const actions: ActionTree<UserState, RootState> = {
store && (preferredStore = store)
}
commit(types.USER_INFO_UPDATED, userProfile);
commit(types.USER_CURRENT_FACILITY_UPDATED, payload.facility);
commit(types.USER_CURRENT_ECOM_STORE_UPDATED, preferredStore);
this.dispatch('order/clearOrders')
await dispatch('getDisableShipNowConfig')
Expand Down
1 change: 0 additions & 1 deletion src/store/modules/user/mutation-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export const SN_USER = 'user'
export const USER_TOKEN_CHANGED = SN_USER + '/TOKEN_CHANGED'
export const USER_END_SESSION = SN_USER + '/END_SESSION'
export const USER_INFO_UPDATED = SN_USER + '/INFO_UPDATED'
export const USER_CURRENT_FACILITY_UPDATED = SN_USER + '/CURRENT_FACILITY_UPDATED'
export const USER_INSTANCE_URL_UPDATED = SN_USER + '/INSTANCE_URL_UPDATED'
export const USER_CURRENT_ECOM_STORE_UPDATED = SN_USER + '/CURRENT_ECOM_STORE_UPDATED'
export const USER_PREFERENCE_UPDATED = SN_USER + '/PREFERENCE_UPDATED'
Expand Down
6 changes: 3 additions & 3 deletions src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

<section>
<DxpOmsInstanceNavigator />
<DxpFacilitySwitcher @updateFacility="updateFacility()"/>
<DxpFacilitySwitcher @updateFacility="updateFacility($event)"/>

<ion-card>
<ion-card-header>
Expand Down Expand Up @@ -452,9 +452,9 @@ export default defineComponent({
this.updateOrderLimitType()
}
},
async updateFacility() {
async updateFacility(facility: any) {
await this.store.dispatch('user/setFacility', facility);
await this.store.dispatch('user/fetchNotificationPreferences')
this.store.dispatch('order/clearOrders')
this.getCurrentFacilityDetails();
this.getFacilityOrderCount();
this.getEcomInvStatus();
Expand Down
Loading