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: code to get 'eComStores' in 'getProfile' action instead of calling 'getEcomStores' action(#257v6ck) #226

Merged
merged 7 commits into from
Aug 23, 2022
22 changes: 5 additions & 17 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,18 @@ const actions: ActionTree<UserState, RootState> = {
"noConditionFind": "Y"
}

await dispatch('getEComStores', payload).then((stores: any) => {
const storeResp = await UserService.getEComStores(payload);
if(storeResp.status === 200 && !hasError(storeResp) && storeResp.data.docs?.length > 0) {
const stores = storeResp.data.docs;

resp.data.stores = [
...(stores ? stores : []),
{
productStoreId: "",
storeName: "None"
}
]
})
}
const currentProductStoreId = resp.data?.stores[0].productStoreId;
if (currentProductStoreId) {
dispatch('getShopifyConfig', currentProductStoreId);
Expand Down Expand Up @@ -169,21 +172,6 @@ const actions: ActionTree<UserState, RootState> = {
commit(types.USER_CURRENT_SHOPIFY_CONFIG_UPDATED, id);
},

async getEComStores(_context, payload) {
let resp;

try{
resp = await UserService.getEComStores(payload);
if (resp.status === 200 && resp.data.docs?.length > 0 && !hasError(resp)) {
const stores = resp.data.docs

return stores
}
} catch(err) {
console.error(err)
}
},

async setEComStore({ commit }, payload) {
commit(types.USER_CURRENT_ECOM_STORE_UPDATED, payload.store);
},
Expand Down