Skip to content

Commit

Permalink
Improved: used api method for fetching the ecomStores (hotwax#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
amansinghbais committed Dec 5, 2024
1 parent 7a38081 commit daf05da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
17 changes: 5 additions & 12 deletions src/services/UserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,7 @@ const getUserPermissions = async (payload: any, token: any): Promise<any> => {
}
}

async function getEComStores(token: any): Promise<any> {
const baseURL = store.getters['user/getBaseUrl'];

async function getEComStores(): Promise<any> {
const params = {
"viewSize": 200,
"fieldList": ["productStoreId", "storeName"],
Expand All @@ -155,17 +153,12 @@ async function getEComStores(token: any): Promise<any> {
};

try {
const resp = await client({
const resp = await api({
url: "performFind",
method: "get",
baseURL,
params,
headers: {
Authorization: 'Bearer ' + token,
'Content-Type': 'application/json'
}
});
if(resp.status === 200 && !hasError(resp)) {
params
}) as any;
if(!hasError(resp)) {
return Promise.resolve(resp.data.docs?.length ? resp.data.docs : []);
} else {
throw resp.data
Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const actions: ActionTree<UserState, RootState> = {
await dispatch('getProfile')
dispatch('setPreferredDateTimeFormat', process.env.VUE_APP_DATE_FORMAT ? process.env.VUE_APP_DATE_FORMAT : 'MM/dd/yyyy');

const ecomStores = await UserService.getEComStores(token)
const ecomStores = await UserService.getEComStores()
useUserStore().$state.eComStores = ecomStores
await useUserStore().getEComStorePreference("SELECTED_BRAND")
const preferredStore: any = useUserStore().getCurrentEComStore
Expand Down

0 comments on commit daf05da

Please sign in to comment.