-
Notifications
You must be signed in to change notification settings - Fork 32
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
Refactored: setEcomStore and setShopifyConfig actions to accept ID. (#2tzh44d) #241
Changes from 7 commits
383b385
25b04b9
06f37a2
87dc4ed
0fd3d5c
c7c082d
8d22484
57fe77e
e064808
a41a43a
e5385f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -130,13 +130,20 @@ const actions: ActionTree<UserState, RootState> = { | |||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||
* update current eComStore information | ||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||
async setEcomStore({ commit, dispatch }, payload) { | ||||||||||||||||||||||||||
async setEcomStore({ commit, dispatch, getters }, payload) { | ||||||||||||||||||||||||||
dispatch('job/clearJobState', null, { root: true }); | ||||||||||||||||||||||||||
commit(types.USER_CURRENT_ECOM_STORE_UPDATED, payload.eComStore); | ||||||||||||||||||||||||||
dispatch('getShopifyConfig', payload.eComStore.productStoreId); | ||||||||||||||||||||||||||
let productStore; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if(payload.productStore) { | ||||||||||||||||||||||||||
commit(types.USER_CURRENT_ECOM_STORE_UPDATED, payload.productStore); | ||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||
productStore = getters.getUserProfile.stores.find((store: any) => store.productStoreId === payload.productStoreId); | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to use getter, I think we could directly access the state |
||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
dispatch('getShopifyConfig', productStore ? productStore.productStoreId : payload.productStore.productStoreId); | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once we have |
||||||||||||||||||||||||||
await UserService.setUserPreference({ | ||||||||||||||||||||||||||
'userPrefTypeId': 'SELECTED_BRAND', | ||||||||||||||||||||||||||
'userPrefValue': payload.eComStore.productStoreId | ||||||||||||||||||||||||||
'userPrefValue': productStore ? productStore.productStoreId : payload.productStore.productStoreId | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. refer my previous comment |
||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||
|
@@ -204,9 +211,16 @@ const actions: ActionTree<UserState, RootState> = { | |||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||
* update current shopify config id | ||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||
async setCurrentShopifyConfig({ commit, dispatch }, shopifyConfig) { | ||||||||||||||||||||||||||
commit(types.USER_CURRENT_SHOPIFY_CONFIG_UPDATED, shopifyConfig ? shopifyConfig : {}); | ||||||||||||||||||||||||||
dispatch('job/clearJobState', null, { root: true }); | ||||||||||||||||||||||||||
async setCurrentShopifyConfig({ commit, dispatch, state }, payload) { | ||||||||||||||||||||||||||
if(payload.shopifyConfig) { | ||||||||||||||||||||||||||
commit(types.USER_CURRENT_SHOPIFY_CONFIG_UPDATED, payload.shopifyConfig); | ||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||
const shopifyConfigs = state.shopifyConfigs; | ||||||||||||||||||||||||||
const currentShopifyConfig = shopifyConfigs.find((configs: any) => configs.shopifyConfigId === payload.shopifyConfigId) | ||||||||||||||||||||||||||
commit(types.USER_CURRENT_SHOPIFY_CONFIG_UPDATED, currentShopifyConfig); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest following code for better readability
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
dispatch('job/clearJobState', null, { root: true }); | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -88,14 +88,14 @@ export default defineComponent({ | |||||||
methods: { | ||||||||
setEComStore(store: any) { | ||||||||
if(this.userProfile) { | ||||||||
this.store.dispatch('user/setEcomStore', { | ||||||||
'eComStore': this.userProfile.stores.find((str: any) => str.productStoreId == store['detail'].value) | ||||||||
}) | ||||||||
const productStoreId = store['detail'].value | ||||||||
this.store.dispatch('user/setEcomStore', { 'productStoreId': productStoreId }) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, we could rename store to event like |
||||||||
} | ||||||||
}, | ||||||||
setShopifyConfig(event: any){ | ||||||||
const shopifyConfig = this.shopifyConfigs.find((shopifyConfig: any) => shopifyConfig.shopifyConfigId === event.detail.value) | ||||||||
this.store.dispatch('user/setCurrentShopifyConfig', shopifyConfig); | ||||||||
// const currentShopifyConfig = this.shopifyConfigs.find((shopifyConfig: any) => shopifyConfig.shopifyConfigId === event.detail.value); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove unwanted code |
||||||||
const shopifyConfigId = event.detail.value; | ||||||||
this.store.dispatch('user/setCurrentShopifyConfig', { 'shopifyConfigId': shopifyConfigId }); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implemented the changes, sir, please review. |
||||||||
}, | ||||||||
async changeTimeZone() { | ||||||||
const timeZoneModal = await modalController.create({ | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should commit in both the cases, here we should assign productStore with payload.productStore