diff --git a/package-lock.json b/package-lock.json index 7f221675..da2f956a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19141,4 +19141,4 @@ "dev": true } } -} +} \ No newline at end of file diff --git a/src/App.vue b/src/App.vue index 17313685..e03fc0b4 100644 --- a/src/App.vue +++ b/src/App.vue @@ -17,7 +17,7 @@ import { mapGetters, useStore } from 'vuex'; import { initialise, resetConfig } from '@/adapter' import { useRouter } from 'vue-router'; import { Settings } from 'luxon' -import { translate, useProductIdentificationStore } from '@hotwax/dxp-components'; +import { translate, useProductIdentificationStore, useUserStore } from '@hotwax/dxp-components'; import logger from '@/logger' import { init, loadRemote } from '@module-federation/runtime'; @@ -41,7 +41,6 @@ export default defineComponent({ instanceUrl: 'user/getInstanceUrl', userProfile: 'user/getUserProfile', locale: 'user/getLocale', - currentEComStore: 'user/getCurrentEComStore' }) }, methods: { @@ -138,11 +137,12 @@ export default defineComponent({ Settings.defaultZone = this.userProfile.userTimeZone; } + const currentEComStore: any = useUserStore().getCurrentEComStore; // If fetching identifier without checking token then on login the app stucks in a loop, as the mounted hook runs before // token is available which results in api failure as unauthenticated, thus making logout call and then login call again and so on. - if(this.userToken) { + if(this.userToken && currentEComStore?.productStoreId) { // Get product identification from api using dxp-component - await useProductIdentificationStore().getIdentificationPref(this.currentEComStore?.productStoreId) + await useProductIdentificationStore().getIdentificationPref(currentEComStore.productStoreId) .catch((error) => logger.error(error)); } }, diff --git a/src/adapter/index.ts b/src/adapter/index.ts index 657e0939..bf47f596 100644 --- a/src/adapter/index.ts +++ b/src/adapter/index.ts @@ -1,6 +1,6 @@ import { api, client, getConfig, getNotificationEnumIds, getNotificationUserPrefTypeIds, getProductIdentificationPref, fetchGoodIdentificationTypes, getUserFacilities, getUserPreference, hasError, initialise, logout, removeClientRegistrationToken, resetConfig, setProductIdentificationPref, setUserLocale, storeClientRegistrationToken, - subscribeTopic, unsubscribeTopic, updateInstanceUrl, updateToken, setUserTimeZone, setUserPreference, getAvailableTimeZones } from '@hotwax/oms-api' + subscribeTopic, unsubscribeTopic, updateInstanceUrl, updateToken, setUserTimeZone, setUserPreference, getAvailableTimeZones, getEComStoresByFacility } from '@hotwax/oms-api' export { api, @@ -26,5 +26,6 @@ export { updateToken, setUserTimeZone, setUserPreference, - getAvailableTimeZones + getAvailableTimeZones, + getEComStoresByFacility } \ No newline at end of file diff --git a/src/components/TransferOrderFilters.vue b/src/components/TransferOrderFilters.vue index c231ae70..ccc301e4 100644 --- a/src/components/TransferOrderFilters.vue +++ b/src/components/TransferOrderFilters.vue @@ -80,7 +80,6 @@ export default defineComponent({ transferOrders: 'transferorder/getTransferOrders', getStatusDesc: 'util/getStatusDesc', getShipmentMethodDesc: 'util/getShipmentMethodDesc', - currentEComStore: 'user/getCurrentEComStore', }) }, async mounted() { @@ -173,7 +172,8 @@ export default defineComponent({ const store = useStore(); const userStore = useUserStore() let currentFacility: any = computed(() => userStore.getCurrentFacility) - + let currentEComStore: any = computed(() => userStore.getCurrentEComStore) + return { albumsOutline, banOutline, @@ -182,6 +182,7 @@ export default defineComponent({ checkmarkDoneOutline, closeOutline, currentFacility, + currentEComStore, filterOutline, iceCreamOutline, libraryOutline, diff --git a/src/index.ts b/src/index.ts index aa6a61e4..cca5a33b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -31,7 +31,7 @@ import permissionRules from '@/authorization/Rules'; import permissionActions from '@/authorization/Actions'; import { dxpComponents } from '@hotwax/dxp-components'; import { login, logout, loader } from '@/utils/user'; -import { getConfig, fetchGoodIdentificationTypes, getProductIdentificationPref, getUserFacilities, getUserPreference, initialise, setProductIdentificationPref, setUserLocale, getAvailableTimeZones, setUserTimeZone, +import { getConfig, fetchGoodIdentificationTypes, getEComStoresByFacility, getProductIdentificationPref, getUserFacilities, getUserPreference, initialise, setProductIdentificationPref, setUserLocale, getAvailableTimeZones, setUserTimeZone, setUserPreference } from './adapter'; import localeMessages from '@/locales'; import { addNotification, storeClientRegistrationToken } from '@/utils/firebase'; @@ -62,6 +62,7 @@ const app = createApp(App) appFirebaseVapidKey: process.env.VUE_APP_FIREBASE_VAPID_KEY, getConfig, fetchGoodIdentificationTypes, + getEComStoresByFacility, getProductIdentificationPref, initialise, setProductIdentificationPref, diff --git a/src/main.ts b/src/main.ts index f75fb140..797be269 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1 +1 @@ -import("./index") +import("./index") \ No newline at end of file diff --git a/src/services/UserService.ts b/src/services/UserService.ts index 0fbdb968..d145bcae 100644 --- a/src/services/UserService.ts +++ b/src/services/UserService.ts @@ -85,49 +85,6 @@ const recycleOutstandingOrders = async(payload: any): Promise => { }) } -const getEComStores = async (token: any, facility: any): Promise => { - try { - const params = { - "inputFields": { - "storeName_op": "not-empty", - facilityId: facility.facilityId - }, - "fieldList": ["productStoreId", "storeName"], - "entityName": "ProductStoreFacilityDetail", - "distinct": "Y", - "noConditionFind": "Y", - "filterByDate": 'Y', - } - const baseURL = store.getters['user/getBaseUrl']; - const resp = await client({ - url: "performFind", - method: "get", - baseURL, - params, - headers: { - Authorization: 'Bearer ' + token, - 'Content-Type': 'application/json' - } - }); - if (hasError(resp)) { - // Following promise reject pattern as OMS api, to show error message on the login page. - return Promise.reject({ - code: 'error', - message: `Failed to fetch product stores for ${facility.facilityName} facility.`, - serverResponse: resp.data - }) - } else { - return Promise.resolve(resp.data.docs); - } - } catch(error: any) { - return Promise.reject({ - code: 'error', - message: 'Something went wrong', - serverResponse: error - }) - } -} - const getPreferredStore = async (token: any): Promise => { const baseURL = store.getters['user/getBaseUrl']; try { @@ -416,7 +373,6 @@ export const UserService = { getCollateralRejectionConfig, getDisableShipNowConfig, getDisableUnpackConfig, - getEComStores, getFacilityDetails, getFacilityOrderCount, getFieldMappings, diff --git a/src/store/modules/carrier/actions.ts b/src/store/modules/carrier/actions.ts index 2f30ab6e..ec6db545 100644 --- a/src/store/modules/carrier/actions.ts +++ b/src/store/modules/carrier/actions.ts @@ -7,7 +7,7 @@ import * as types from './mutation-types' import logger from '@/logger' import store from '@/store'; import { translate } from '@hotwax/dxp-components'; -import { showToast, isValidCarrierCode, isValidDeliveryDays, getCurrentFacilityId } from '@/utils'; +import { showToast, isValidCarrierCode, isValidDeliveryDays, getCurrentFacilityId, getProductStoreId } from '@/utils'; const actions: ActionTree = { @@ -437,7 +437,7 @@ const actions: ActionTree = { "entityName": "ProductStoreShipmentMethView", "inputFields": { "roleTypeId": "CARRIER", - "productStoreId": this.state.user.currentEComStore.productStoreId, + "productStoreId": getProductStoreId(), "shipmentMethodTypeId": "STOREPICKUP", "shipmentMethodTypeId_op": "notEqual" }, diff --git a/src/store/modules/order/actions.ts b/src/store/modules/order/actions.ts index 5517cf84..84da2fbf 100644 --- a/src/store/modules/order/actions.ts +++ b/src/store/modules/order/actions.ts @@ -9,7 +9,7 @@ import { escapeSolrSpecialChars, prepareOrderQuery } from '@/utils/solrHelper' import { UtilService } from '@/services/UtilService' import logger from '@/logger' import { getOrderCategory, removeKitComponents } from '@/utils/order' -import { getCurrentFacilityId } from '@/utils' +import { getCurrentFacilityId, getProductStoreId } from '@/utils' const actions: ActionTree = { async fetchInProgressOrdersAdditionalInformation({ commit, dispatch, state }, payload = { viewIndex: 0 }) { @@ -326,7 +326,7 @@ const actions: ActionTree = { '-fulfillmentStatus': { value: ['Rejected', 'Cancelled'] }, '-shipmentMethodTypeId': { value: 'STOREPICKUP' }, facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) }, - productStoreId: { value: this.state.user.currentEComStore.productStoreId } + productStoreId: { value: getProductStoreId() } } } @@ -420,7 +420,7 @@ const actions: ActionTree = { orderStatusId: { value: 'ORDER_APPROVED' }, orderTypeId: { value: 'SALES_ORDER' }, facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) }, - productStoreId: { value: this.state.user.currentEComStore.productStoreId } + productStoreId: { value: getProductStoreId() } } } @@ -491,7 +491,7 @@ const actions: ActionTree = { picklistItemStatusId: { value: '(PICKITEM_PICKED OR (PICKITEM_COMPLETED AND itemShippedDate: [NOW/DAY TO NOW/DAY+1DAY]))' }, '-shipmentMethodTypeId': { value: 'STOREPICKUP' }, facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) }, - productStoreId: { value: this.state.user.currentEComStore.productStoreId } + productStoreId: { value: getProductStoreId() } } } @@ -774,7 +774,7 @@ const actions: ActionTree = { orderStatusId: { value: 'ORDER_APPROVED' }, orderTypeId: { value: 'SALES_ORDER' }, facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) }, - productStoreId: { value: this.state.user.currentEComStore.productStoreId } + productStoreId: { value: getProductStoreId() } } } const orderQueryPayload = prepareOrderQuery(params) @@ -843,7 +843,7 @@ const actions: ActionTree = { '-fulfillmentStatus': { value: ['Cancelled', 'Rejected']}, '-shipmentMethodTypeId': { value: 'STOREPICKUP' }, facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) }, - productStoreId: { value: this.state.user.currentEComStore.productStoreId } + productStoreId: { value: getProductStoreId() } } } @@ -910,7 +910,7 @@ const actions: ActionTree = { '-shipmentMethodTypeId': { value: 'STOREPICKUP' }, shipGroupSeqId: { value: payload.shipGroupSeqId }, facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) }, - productStoreId: { value: this.state.user.currentEComStore.productStoreId } + productStoreId: { value: getProductStoreId() } } } diff --git a/src/store/modules/transferorder/actions.ts b/src/store/modules/transferorder/actions.ts index c926cb8f..e173fc10 100644 --- a/src/store/modules/transferorder/actions.ts +++ b/src/store/modules/transferorder/actions.ts @@ -8,7 +8,7 @@ import * as types from './mutation-types' import { escapeSolrSpecialChars, prepareOrderQuery } from '@/utils/solrHelper' import logger from '@/logger' import { getProductIdentificationValue, translate } from '@hotwax/dxp-components' -import { showToast, getCurrentFacilityId } from "@/utils"; +import { showToast, getCurrentFacilityId, getProductStoreId } from "@/utils"; import { UtilService } from '@/services/UtilService' import store from "@/store"; @@ -30,7 +30,7 @@ const actions: ActionTree = { filters: { orderTypeId: { value: 'TRANSFER_ORDER' }, facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) }, - productStoreId: { value: this.state.user.currentEComStore.productStoreId } + productStoreId: { value: getProductStoreId() } } } diff --git a/src/store/modules/user/UserState.ts b/src/store/modules/user/UserState.ts index 7cdd85b2..34bc18ad 100644 --- a/src/store/modules/user/UserState.ts +++ b/src/store/modules/user/UserState.ts @@ -4,7 +4,6 @@ export default interface UserState { permissions: any; pwaState: any; instanceUrl: string; - currentEComStore: object; preference: { printShippingLabel: boolean, printPackingSlip: boolean diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index 047fa600..f0fe0341 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -4,7 +4,7 @@ import RootState from '@/store/RootState' import store from '@/store'; import UserState from './UserState' import * as types from './mutation-types' -import { showToast, getCurrentFacilityId } from '@/utils' +import { showToast, getCurrentFacilityId, getProductStoreId } from '@/utils' import { hasError } from '@/adapter' import { translate } from '@hotwax/dxp-components' import { DateTime, Settings } from 'luxon'; @@ -71,15 +71,9 @@ const actions: ActionTree = { // TODO Use a separate API for getting facilities, this should handle user like admin accessing the app const currentFacility: any = useUserStore().getCurrentFacility - userProfile.stores = await UserService.getEComStores(token, currentFacility); - - let preferredStore = userProfile.stores[0] - - const preferredStoreId = await UserService.getPreferredStore(token); - if (preferredStoreId) { - const store = userProfile.stores.find((store: any) => store.productStoreId === preferredStoreId); - store && (preferredStore = store) - } + userProfile.stores = await useUserStore().getEComStoresByFacility(currentFacility.facilityId); + await useUserStore().getEComStorePreference('SELECTED_BRAND'); + const preferredStore: any = useUserStore().getCurrentEComStore /* ---- Guard clauses ends here --- */ setPermissions(appPermissions); @@ -91,13 +85,12 @@ const actions: ActionTree = { dispatch('getFieldMappings') // TODO user single mutation - commit(types.USER_CURRENT_ECOM_STORE_UPDATED, preferredStore); commit(types.USER_INFO_UPDATED, userProfile); commit(types.USER_PERMISSIONS_UPDATED, appPermissions); commit(types.USER_TOKEN_CHANGED, { newToken: token }) // Get product identification from api using dxp-component - await useProductIdentificationStore().getIdentificationPref(preferredStoreId ? preferredStoreId : preferredStore.productStoreId) + await useProductIdentificationStore().getIdentificationPref(preferredStore.productStoreId) .catch((error) => logger.error(error)); await dispatch("fetchAllNotificationPrefs"); @@ -188,19 +181,12 @@ const actions: ActionTree = { 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, facility); + userProfile.stores = await useUserStore().getEComStoresByFacility(facility.facilityId); + await useUserStore().getEComStorePreference('SELECTED_BRAND'); + const preferredStore: any = useUserStore().getCurrentEComStore - let preferredStore = userProfile.stores[0]; - const preferredStoreId = await UserService.getPreferredStore(token); - - if (preferredStoreId) { - const store = userProfile.stores.find((store: any) => store.productStoreId === preferredStoreId); - store && (preferredStore = store) - } commit(types.USER_INFO_UPDATED, userProfile); - commit(types.USER_CURRENT_ECOM_STORE_UPDATED, preferredStore); this.dispatch('order/clearOrders') await dispatch('getDisableShipNowConfig') await dispatch('getDisableUnpackConfig') @@ -232,22 +218,16 @@ const actions: ActionTree = { /** * update current eComStore information */ - async setEComStore({ commit, dispatch }, payload) { - commit(types.USER_CURRENT_ECOM_STORE_UPDATED, payload.eComStore); - await UserService.setUserPreference({ - 'userPrefTypeId': 'SELECTED_BRAND', - 'userPrefValue': payload.eComStore.productStoreId - }); - + async setEComStore({ commit, dispatch }, productStoreId) { // Get product identification from api using dxp-component - await useProductIdentificationStore().getIdentificationPref(payload.eComStore.productStoreId) + await useProductIdentificationStore().getIdentificationPref(productStoreId) .catch((error) => logger.error(error)); await dispatch('getDisableShipNowConfig') await dispatch('getDisableUnpackConfig') - this.dispatch('util/findProductStoreShipmentMethCount') - this.dispatch('util/getForceScanSetting', payload.eComStore.productStoreId) - this.dispatch('util/fetchBarcodeIdentificationPref', payload.eComStore.productStoreId); + this.dispatch('util/findProductStoreShipmentMethCount'); + this.dispatch('util/getForceScanSetting', productStoreId) + this.dispatch('util/fetchBarcodeIdentificationPref', productStoreId); }, setUserPreference({ commit }, payload){ @@ -431,7 +411,7 @@ const actions: ActionTree = { let config = {}; const params = { "inputFields": { - "productStoreId": this.state.user.currentEComStore.productStoreId, + "productStoreId": getProductStoreId(), "settingTypeEnumId": "FF_USE_NEW_REJ_API" }, "filterByDate": 'Y', @@ -457,7 +437,7 @@ const actions: ActionTree = { let isShipNowDisabled = false; const params = { "inputFields": { - "productStoreId": this.state.user.currentEComStore.productStoreId, + "productStoreId": getProductStoreId(), "settingTypeEnumId": "DISABLE_SHIPNOW" }, "filterByDate": 'Y', @@ -484,7 +464,7 @@ const actions: ActionTree = { let isUnpackDisabled = false; const params = { "inputFields": { - "productStoreId": this.state.user.currentEComStore.productStoreId, + "productStoreId": getProductStoreId(), "settingTypeEnumId": "DISABLE_UNPACK" }, "filterByDate": 'Y', @@ -527,7 +507,7 @@ const actions: ActionTree = { //Create Product Store Setting payload = { ...payload, - "productStoreId": this.state.user.currentEComStore.productStoreId, + "productStoreId": getProductStoreId(), "settingTypeEnumId": "FULFILL_PART_ODR_REJ", "fromDate": DateTime.now().toMillis() } @@ -571,7 +551,7 @@ const actions: ActionTree = { //Create Product Store Setting payload = { ...payload, - "productStoreId": this.state.user.currentEComStore.productStoreId, + "productStoreId": getProductStoreId(), "settingTypeEnumId": "FF_COLLATERAL_REJ", "fromDate": DateTime.now().toMillis() } @@ -598,7 +578,7 @@ const actions: ActionTree = { let config = {}; const params = { "inputFields": { - "productStoreId": this.state.user.currentEComStore.productStoreId, + "productStoreId": getProductStoreId(), "settingTypeEnumId": "FULFILL_PART_ODR_REJ" }, "filterByDate": 'Y', @@ -623,7 +603,7 @@ const actions: ActionTree = { let config = {}; const params = { "inputFields": { - "productStoreId": this.state.user.currentEComStore.productStoreId, + "productStoreId": getProductStoreId(), "settingTypeEnumId": "FF_COLLATERAL_REJ" }, "filterByDate": 'Y', diff --git a/src/store/modules/user/getters.ts b/src/store/modules/user/getters.ts index 8dde5e31..86ea8725 100644 --- a/src/store/modules/user/getters.ts +++ b/src/store/modules/user/getters.ts @@ -27,9 +27,6 @@ const getters: GetterTree = { if (!baseURL) baseURL = state.instanceUrl; return baseURL.startsWith('http') ? baseURL.includes('/api') ? baseURL : `${baseURL}/api/` : `https://${baseURL}.hotwax.io/api/`; }, - getCurrentEComStore(state) { - return state.currentEComStore - }, getUserPreference(state) { return state.preference }, diff --git a/src/store/modules/user/index.ts b/src/store/modules/user/index.ts index 6a1fe3d1..d2f0f427 100644 --- a/src/store/modules/user/index.ts +++ b/src/store/modules/user/index.ts @@ -12,7 +12,6 @@ const userModule: Module = { permissions: [], current: {}, instanceUrl: '', - currentEComStore: {}, preference: { printShippingLabel: false, printPackingSlip: false diff --git a/src/store/modules/user/mutation-types.ts b/src/store/modules/user/mutation-types.ts index 4b6861d0..3ba34cce 100644 --- a/src/store/modules/user/mutation-types.ts +++ b/src/store/modules/user/mutation-types.ts @@ -3,7 +3,6 @@ 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_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' export const USER_PERMISSIONS_UPDATED = SN_USER + '/PERMISSIONS_UPDATED' export const USER_CURRENT_FIELD_MAPPING_UPDATED = SN_USER + '/_CURRENT_FIELD_MAPPING_UPDATED' diff --git a/src/store/modules/user/mutations.ts b/src/store/modules/user/mutations.ts index a999e2e0..684cab44 100644 --- a/src/store/modules/user/mutations.ts +++ b/src/store/modules/user/mutations.ts @@ -9,7 +9,6 @@ const mutations: MutationTree = { [types.USER_END_SESSION] (state) { state.token = '' state.current = {}, - state.currentEComStore = {} state.permissions = [], state.allNotificationPrefs = [] }, @@ -19,9 +18,6 @@ const mutations: MutationTree = { [types.USER_INSTANCE_URL_UPDATED] (state, payload) { state.instanceUrl = payload; }, - [types.USER_CURRENT_ECOM_STORE_UPDATED](state, payload) { - state.currentEComStore = payload; - }, [types.USER_PREFERENCE_UPDATED] (state, payload) { state.preference = {...state.preference, ...payload}; }, diff --git a/src/store/modules/util/actions.ts b/src/store/modules/util/actions.ts index c3596153..3e1f984c 100644 --- a/src/store/modules/util/actions.ts +++ b/src/store/modules/util/actions.ts @@ -6,7 +6,7 @@ import { UtilService } from '@/services/UtilService' import { hasError } from '@/adapter' import logger from '@/logger' import store from '@/store'; -import { showToast } from '@/utils' +import { showToast, getProductStoreId } from '@/utils' import { translate } from '@hotwax/dxp-components' const actions: ActionTree = { @@ -348,7 +348,7 @@ const actions: ActionTree = { "partyId": "_NA_", "partyId_op": "notEqual", "roleTypeId": "CARRIER", - "productStoreId": this.state.user.currentEComStore.productStoreId + "productStoreId": getProductStoreId() }, "fieldList": ['roleTypeId', "partyId"], "viewSize": 1 @@ -539,7 +539,6 @@ const actions: ActionTree = { }, async createForceScanSetting({ commit }) { - const ecomStore = store.getters['user/getCurrentEComStore']; const fromDate = Date.now() try { @@ -559,7 +558,7 @@ const actions: ActionTree = { const params = { fromDate, - "productStoreId": ecomStore.productStoreId, + "productStoreId": getProductStoreId(), "settingTypeEnumId": "FULFILL_FORCE_SCAN", "settingValue": "false" } @@ -577,7 +576,7 @@ const actions: ActionTree = { async setForceScanSetting({ commit, dispatch, state }, value) { let prefValue = state.isForceScanEnabled - const eComStoreId = store.getters['user/getCurrentEComStore'].productStoreId; + const eComStoreId: any = getProductStoreId(); // when selecting none as ecom store, not updating the pref as it's not possible to save pref with empty productStoreId if(!eComStoreId) { @@ -660,7 +659,6 @@ const actions: ActionTree = { }, async createBarcodeIdentificationPref({ commit }) { - const ecomStore = store.getters['user/getCurrentEComStore']; const fromDate = Date.now() try { @@ -680,7 +678,7 @@ const actions: ActionTree = { const params = { fromDate, - "productStoreId": ecomStore.productStoreId, + "productStoreId": getProductStoreId(), "settingTypeEnumId": "BARCODE_IDEN_PREF", "settingValue": "internalName" } @@ -698,7 +696,7 @@ const actions: ActionTree = { async setBarcodeIdentificationPref({ commit, dispatch, state }, value) { let prefValue = state.barcodeIdentificationPref - const eComStoreId = store.getters['user/getCurrentEComStore'].productStoreId; + const eComStoreId = getProductStoreId() // when selecting none as ecom store, not updating the pref as it's not possible to save pref with empty productStoreId if(!eComStoreId) { diff --git a/src/utils/index.ts b/src/utils/index.ts index 9fd3aa1b..de230d58 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -222,6 +222,11 @@ const getCurrentFacilityId = () => { return currentFacility?.facilityId } +const getProductStoreId = () => { + const currentEComStore: any = useUserStore().getCurrentEComStore; + return currentEComStore.productStoreId +}; + function getDateWithOrdinalSuffix(time: any) { if (!time) return "-"; const dateTime = DateTime.fromMillis(time); @@ -229,4 +234,4 @@ function getDateWithOrdinalSuffix(time: any) { return `${dateTime.day}${suffix} ${dateTime.toFormat("MMM yyyy")}`; } -export { copyToClipboard, formatCurrency, formatDate, formatPhoneNumber, formatUtcDate, generateInternalId, getCurrentFacilityId, getColorByDesc, getDateWithOrdinalSuffix, getFeature, getIdentificationId, handleDateTimeInput, isValidDeliveryDays, isValidCarrierCode, isPdf, showToast, sortItems, hasError, parseCsv, jsonToCsv } +export { copyToClipboard, formatCurrency, formatDate, formatPhoneNumber, formatUtcDate, generateInternalId, getCurrentFacilityId, getProductStoreId, getColorByDesc, getDateWithOrdinalSuffix, getFeature, getIdentificationId, handleDateTimeInput, isValidDeliveryDays, isValidCarrierCode, isPdf, showToast, sortItems, hasError, parseCsv, jsonToCsv } diff --git a/src/views/Completed.vue b/src/views/Completed.vue index fe072cd2..ce4d28e3 100644 --- a/src/views/Completed.vue +++ b/src/views/Completed.vue @@ -207,12 +207,11 @@ import { useRouter } from 'vue-router'; import { mapGetters, useStore } from 'vuex' import { copyToClipboard, formatUtcDate, getFeature, showToast } from '@/utils' import { hasError } from '@/adapter' -import { getProductIdentificationValue, DxpShopifyImg, useProductIdentificationStore } from '@hotwax/dxp-components'; +import { getProductIdentificationValue, DxpShopifyImg, translate, useProductIdentificationStore, useUserStore } from '@hotwax/dxp-components'; import { UtilService } from '@/services/UtilService'; import { prepareOrderQuery } from '@/utils/solrHelper'; import emitter from '@/event-bus'; import ViewSizeSelector from '@/components/ViewSizeSelector.vue' -import { translate, useUserStore } from '@hotwax/dxp-components' import { OrderService } from '@/services/OrderService'; import logger from '@/logger'; import ShippingLabelErrorModal from '@/components/ShippingLabelErrorModal.vue'; @@ -264,7 +263,6 @@ export default defineComponent({ ...mapGetters({ completedOrders: 'order/getCompletedOrders', getProduct: 'product/getProduct', - currentEComStore: 'user/getCurrentEComStore', getPartyName: 'util/getPartyName', getShipmentMethodDesc: 'util/getShipmentMethodDesc', getProductStock: 'stock/getProductStock', @@ -763,6 +761,7 @@ export default defineComponent({ const userStore = useUserStore() const productIdentificationStore = useProductIdentificationStore(); let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref) + let currentEComStore: any = computed(() => userStore.getCurrentEComStore) let currentFacility: any = computed(() => userStore.getCurrentFacility) return { @@ -772,6 +771,7 @@ export default defineComponent({ copyToClipboard, checkmarkDoneOutline, cubeOutline, + currentEComStore, currentFacility, downloadOutline, ellipsisVerticalOutline, diff --git a/src/views/InProgress.vue b/src/views/InProgress.vue index 5e782c36..c5d27d02 100644 --- a/src/views/InProgress.vue +++ b/src/views/InProgress.vue @@ -296,11 +296,10 @@ import { mapGetters, useStore } from 'vuex'; import { copyToClipboard, formatUtcDate, getFeature, jsonToCsv, showToast } from '@/utils'; import { isKit } from '@/utils/order' import { hasError } from '@/adapter'; -import { getProductIdentificationValue, DxpShopifyImg, useProductIdentificationStore } from '@hotwax/dxp-components'; +import { getProductIdentificationValue, DxpShopifyImg, translate, useProductIdentificationStore, useUserStore } from '@hotwax/dxp-components'; import ViewSizeSelector from '@/components/ViewSizeSelector.vue'; import { OrderService } from '@/services/OrderService'; import emitter from '@/event-bus'; -import { translate, useUserStore } from '@hotwax/dxp-components'; import { prepareOrderQuery } from '@/utils/solrHelper'; import { UtilService } from '@/services/UtilService'; import { DateTime } from 'luxon'; @@ -359,7 +358,6 @@ export default defineComponent({ inProgressOrders: 'order/getInProgressOrders', getProduct: 'product/getProduct', rejectReasonOptions: 'util/getRejectReasonOptions', - currentEComStore: 'user/getCurrentEComStore', userPreference: 'user/getUserPreference', boxTypeDesc: 'util/getShipmentBoxDesc', getProductStock: 'stock/getProductStock', @@ -1329,6 +1327,7 @@ export default defineComponent({ const userStore = useUserStore() const productIdentificationStore = useProductIdentificationStore(); let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref) + let currentEComStore: any = computed(() => userStore.getCurrentEComStore) let currentFacility: any = computed(() => userStore.getCurrentFacility) return { @@ -1341,6 +1340,7 @@ export default defineComponent({ checkmarkDoneOutline, closeCircleOutline, cubeOutline, + currentEComStore, currentFacility, ellipsisVerticalOutline, fileTrayOutline, diff --git a/src/views/OpenOrders.vue b/src/views/OpenOrders.vue index e02a11ec..de58a04a 100644 --- a/src/views/OpenOrders.vue +++ b/src/views/OpenOrders.vue @@ -220,7 +220,6 @@ export default defineComponent({ ...mapGetters({ openOrders: 'order/getOpenOrders', getProduct: 'product/getProduct', - currentEComStore: 'user/getCurrentEComStore', getShipmentMethodDesc: 'util/getShipmentMethodDesc', getProductStock: 'stock/getProductStock', notifications: 'user/getNotifications', @@ -435,12 +434,14 @@ export default defineComponent({ const productIdentificationStore = useProductIdentificationStore(); let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref) let currentFacility: any = computed(() => userStore.getCurrentFacility) + let currentEComStore: any = computed(() => userStore.getCurrentEComStore) return{ Actions, caretDownOutline, chevronUpOutline, cubeOutline, + currentEComStore, currentFacility, formatUtcDate, getFeature, diff --git a/src/views/OrderDetail.vue b/src/views/OrderDetail.vue index d43d1a26..46ea3ac4 100644 --- a/src/views/OrderDetail.vue +++ b/src/views/OrderDetail.vue @@ -476,7 +476,6 @@ export default defineComponent({ ...mapGetters({ boxTypeDesc: 'util/getShipmentBoxDesc', completedOrders: 'order/getCompletedOrders', - currentEComStore: 'user/getCurrentEComStore', getProduct: 'product/getProduct', getProductStock: 'stock/getProductStock', inProgressOrders: 'order/getInProgressOrders', @@ -1683,6 +1682,7 @@ export default defineComponent({ const productIdentificationStore = useProductIdentificationStore(); let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref) let currentFacility: any = computed(() => userStore.getCurrentFacility) + let currentEComStore: any = computed(() => userStore.getCurrentEComStore) return { addOutline, @@ -1695,6 +1695,7 @@ export default defineComponent({ closeCircleOutline, copyToClipboard, cubeOutline, + currentEComStore, currentFacility, documentTextOutline, ellipsisVerticalOutline, diff --git a/src/views/OrderLookupDetail.vue b/src/views/OrderLookupDetail.vue index 935790b7..1a36a67e 100644 --- a/src/views/OrderLookupDetail.vue +++ b/src/views/OrderLookupDetail.vue @@ -112,7 +112,7 @@ {{ translate("Brand") }} - {{ currentEcomStore.storeName || "-" }} + {{ currentEComStore.storeName || "-" }} {{ translate("Channel") }} @@ -280,8 +280,8 @@ import { IonToolbar, popoverController } from "@ionic/vue"; -import { defineComponent } from "vue"; -import { translate } from '@hotwax/dxp-components'; +import { computed, defineComponent } from "vue"; +import { translate, useUserStore } from '@hotwax/dxp-components'; import { cubeOutline, golfOutline, callOutline, cashOutline, closeCircleOutline, ellipsisVerticalOutline, informationCircleOutline, ribbonOutline, mailOutline, ticketOutline, timeOutline, pulseOutline, storefrontOutline, sunnyOutline, checkmarkDoneOutline, downloadOutline } from "ionicons/icons"; import { mapGetters, useStore } from "vuex"; import { DateTime } from "luxon"; @@ -329,7 +329,6 @@ export default defineComponent({ computed: { ...mapGetters({ order: "orderLookup/getCurrentOrder", - currentEcomStore: "user/getCurrentEComStore", getProduct: "product/getProduct", getProductStock: "stock/getProductStock", getStatusDesc: "util/getStatusDesc", @@ -413,6 +412,8 @@ export default defineComponent({ }, setup() { const store = useStore(); + const userStore = useUserStore() + let currentEComStore: any = computed(() => userStore.getCurrentEComStore) return { callOutline, @@ -420,6 +421,7 @@ export default defineComponent({ checkmarkDoneOutline, closeCircleOutline, cubeOutline, + currentEComStore, downloadOutline, ellipsisVerticalOutline, formatCurrency, diff --git a/src/views/Settings.vue b/src/views/Settings.vue index eccc6045..896a2af0 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -39,25 +39,8 @@
+ - - - - {{ translate("Product Store") }} - - - {{ translate("Store") }} - - - - {{ translate('A store represents a company or a unique catalog of products. If your OMS is connected to multiple eCommerce stores selling different collections of products, you may have multiple Product Stores set up in HotWax Commerce.') }} - - - - {{ store.storeName }} - - - @@ -281,7 +264,6 @@ export default defineComponent({ ...mapGetters({ userProfile: 'user/getUserProfile', instanceUrl: 'user/getInstanceUrl', - currentEComStore: 'user/getCurrentEComStore', userPreference: 'user/getUserPreference', locale: 'user/getLocale', notificationPrefs: 'user/getNotificationPrefs', @@ -307,6 +289,9 @@ export default defineComponent({ await this.store.dispatch('user/fetchNotificationPreferences') }, methods: { + updateEComStore(selectedProductStore: any) { + this.store.dispatch('user/setEComStore', selectedProductStore?.productStoreId) + }, useNewRejectionApi() { return this.newRejectionApiConfig && this.newRejectionApiConfig.settingValue && JSON.parse(this.newRejectionApiConfig.settingValue) }, @@ -556,17 +541,6 @@ export default defineComponent({ this.store.dispatch("util/setForceScanSetting", !this.isForceScanEnabled) }, - async setEComStore(event: any) { - // not updating the ecomstore when an empty value is given (on logout) - if (!event.detail.value) { - return; - } - if(this.userProfile) { - await this.store.dispatch('user/setEComStore', { - 'eComStore': this.userProfile.stores.find((str: any) => str.productStoreId == event.detail.value) - }) - } - }, setPrintShippingLabelPreference (ev: any) { this.store.dispatch('user/setUserPreference', { printShippingLabel: ev.detail.checked }) }, diff --git a/src/views/TransferOrders.vue b/src/views/TransferOrders.vue index 1b77234a..b2cf9713 100644 --- a/src/views/TransferOrders.vue +++ b/src/views/TransferOrders.vue @@ -104,7 +104,6 @@ export default defineComponent({ computed: { ...mapGetters({ transferOrders: 'transferorder/getTransferOrders', - currentEComStore: 'user/getCurrentEComStore', getShipmentMethodDesc: 'util/getShipmentMethodDesc', }) },