From 2f0027086da67b82e2fad034892b47d739b09e8c Mon Sep 17 00:00:00 2001 From: k2maan Date: Mon, 9 Jan 2023 13:07:49 +0530 Subject: [PATCH 1/2] Fixed ECommerce options are not visible on settings page (#85zrhj216) --- src/store/modules/user/actions.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index ef0e966d..8a21f65d 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -95,6 +95,14 @@ const actions: ActionTree = { let stores = [] as any; if(storeResp.status === 200 && !hasError(storeResp) && storeResp.data.docs?.length > 0) { stores = [...storeResp.data.docs] + + resp.data.stores = [ + ...(stores ? stores : []), + { + productStoreId: "", + storeName: "None" + } + ] } let userPrefStore = '' From 9487e87eb5e16f550d9e56b780c4b38248013a18 Mon Sep 17 00:00:00 2001 From: k2maan Date: Mon, 9 Jan 2023 15:47:08 +0530 Subject: [PATCH 2/2] Refactored code and made app specific change to show the All option instead of None (#85zrhj216) --- src/store/modules/user/actions.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index 8a21f65d..b9708353 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -80,6 +80,8 @@ const actions: ActionTree = { */ async getProfile ( { commit, dispatch }) { const resp = await UserService.getProfile() + const userProfile = JSON.parse(JSON.stringify(resp.data)); + if (resp.status === 200) { const payload = { "inputFields": { @@ -96,11 +98,14 @@ const actions: ActionTree = { if(storeResp.status === 200 && !hasError(storeResp) && storeResp.data.docs?.length > 0) { stores = [...storeResp.data.docs] - resp.data.stores = [ - ...(stores ? stores : []), + userProfile.stores = [ + ...stores, { + // With the preorder app's use case, the user will get data specific to the product store + // or all the data, for instance, on the products page. either products belonging to the + // selected store are fetched or all the products are fetched. productStoreId: "", - storeName: "None" + storeName: "All" } ] } @@ -116,7 +121,7 @@ const actions: ActionTree = { console.error(err) } dispatch('setEcomStore', { eComStore: userPrefStore ? userPrefStore : stores.length > 0 ? stores[0] : {} }); - commit(types.USER_INFO_UPDATED, resp.data); + commit(types.USER_INFO_UPDATED, userProfile); } },