diff --git a/package-lock.json b/package-lock.json index 4ed998063..3424309d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "@casl/ability": "^6.0.0", "@hotwax/app-version-info": "^1.0.0", "@hotwax/apps-theme": "^1.2.6", - "@hotwax/dxp-components": "^1.15.5", + "@hotwax/dxp-components": "^1.16.0", "@hotwax/oms-api": "^1.16.0", "@ionic/core": "^7.6.0", "@ionic/vue": "^7.6.0", @@ -2807,9 +2807,9 @@ "integrity": "sha512-zpUjGoY7LBlKeiP0V7tonrmoey8HQ5THQmyixQ+IDtrjmEJNBjynW/Ef3gC0FUNNPuVqxWPZdT5CVgaETLGTwg==" }, "node_modules/@hotwax/dxp-components": { - "version": "1.15.5", - "resolved": "https://registry.npmjs.org/@hotwax/dxp-components/-/dxp-components-1.15.5.tgz", - "integrity": "sha512-aOzipZwVk/fL6K7/BShsvE3eYqH8LagEQQpaNCPFtSs18KHgolGQxcKT3dQ1KRLTCmoKJugc7ut9uyxZVL5krg==", + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/@hotwax/dxp-components/-/dxp-components-1.16.0.tgz", + "integrity": "sha512-9HUrR58Sk9H3wryYGWfGfctcM9hRqq9pnLbaShnNf0mZeK/vTAIqqTPHcObfeKXkSaPtrqS6E/1Y/+Ysmv6v5A==", "dependencies": { "@hotwax/oms-api": "^1.8.1", "@ionic/core": "^7.6.0", diff --git a/package.json b/package.json index 7c553217c..cd236770c 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "@casl/ability": "^6.0.0", "@hotwax/app-version-info": "^1.0.0", "@hotwax/apps-theme": "^1.2.6", - "@hotwax/dxp-components": "^1.15.5", + "@hotwax/dxp-components": "^1.16.0", "@hotwax/oms-api": "^1.16.0", "@ionic/core": "^7.6.0", "@ionic/vue": "^7.6.0", diff --git a/src/adapter/index.ts b/src/adapter/index.ts index 912c83bc3..2dfea079d 100644 --- a/src/adapter/index.ts +++ b/src/adapter/index.ts @@ -7,6 +7,7 @@ import { fetchGoodIdentificationTypes, getProductIdentificationPref, getUserFacilities, + getUserPreference, hasError, initialise, logout, @@ -20,7 +21,8 @@ import { updateInstanceUrl, updateToken, getAvailableTimeZones, - setUserTimeZone + setUserTimeZone, + setUserPreference } from '@hotwax/oms-api' export { @@ -32,6 +34,7 @@ export { fetchGoodIdentificationTypes, getProductIdentificationPref, getUserFacilities, + getUserPreference, hasError, initialise, logout, @@ -45,5 +48,6 @@ export { updateInstanceUrl, updateToken, getAvailableTimeZones, - setUserTimeZone + setUserTimeZone, + setUserPreference } \ No newline at end of file diff --git a/src/components/InventoryDetailsPopover.vue b/src/components/InventoryDetailsPopover.vue index b0184a700..4960c3a19 100644 --- a/src/components/InventoryDetailsPopover.vue +++ b/src/components/InventoryDetailsPopover.vue @@ -54,7 +54,6 @@ export default defineComponent({ product: "product/getCurrent", getProductStock: 'stock/getProductStock', getInventoryInformation: 'stock/getInventoryInformation', - currentFacility: 'user/getCurrentFacility', }) }, async beforeMount () { diff --git a/src/components/NotificationPreferenceModal.vue b/src/components/NotificationPreferenceModal.vue index 29773737a..9212500de 100644 --- a/src/components/NotificationPreferenceModal.vue +++ b/src/components/NotificationPreferenceModal.vue @@ -44,10 +44,10 @@ import { modalController, alertController, } from "@ionic/vue"; -import { defineComponent } from "vue"; +import { computed, defineComponent } from "vue"; import { closeOutline, save } from "ionicons/icons"; import { mapGetters, useStore } from "vuex"; -import { translate } from '@hotwax/dxp-components' +import { translate, useUserStore } from '@hotwax/dxp-components' import { showToast } from "@/utils"; import emitter from "@/event-bus" import { generateTopicName } from "@/utils/firebase"; @@ -82,7 +82,6 @@ export default defineComponent({ }, computed: { ...mapGetters({ - currentFacility: 'user/getCurrentFacility', instanceUrl: 'user/getInstanceUrl', notificationPrefs: 'user/getNotificationPrefs' }), @@ -138,7 +137,7 @@ export default defineComponent({ } }, async handleTopicSubscription() { - const facilityId = (this.currentFacility as any).facilityId + const facilityId = this.currentFacility?.facilityId const subscribeRequests = [] as any this.notificationPrefToUpdate.subscribe.map(async (enumId: string) => { const topicName = generateTopicName(facilityId, enumId) @@ -182,9 +181,12 @@ export default defineComponent({ }, setup() { const store = useStore(); + const userStore = useUserStore() + let currentFacility: any = computed(() => userStore.getCurrentFacility) return { closeOutline, + currentFacility, translate, save, store diff --git a/src/components/ProductListItem.vue b/src/components/ProductListItem.vue index 630ba2a45..8ee26f5e2 100644 --- a/src/components/ProductListItem.vue +++ b/src/components/ProductListItem.vue @@ -55,7 +55,6 @@ export default defineComponent({ getProduct: 'product/getProduct', product: "product/getCurrent", getProductStock: 'stock/getProductStock', - currentFacility: 'user/getCurrentFacility', }) }, methods: { diff --git a/src/locales/en.json b/src/locales/en.json index ccbe9b43f..b7cc3f1bb 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -47,6 +47,7 @@ "Failed to print shipping label and packing slip": "Failed to print shipping label and packing slip", "Failed to update product store setting.": "Failed to update product store setting.", "Fetching pickers": "Fetching pickers", + "Fetching facilities": "Fetching facilities", "First name": "First name", "Generate packing slips": "Generate packing slips", "Generate shipping documents": "Generate shipping documents", @@ -75,6 +76,7 @@ "Mismatch": "Mismatch", "More": "More", "New notification received.": "New notification received.", + "No facilities found": "No facilities found", "No items found": "No items found", "No inventory details found": "No inventory details found", "No products found": "No products found", @@ -131,6 +133,7 @@ "Pickers successfully replaced in the picklist with the new selections.": "Pickers successfully replaced in the picklist with the new selections.", "pieces in stock": "pieces in stock", "Print picklists": "Print picklists", + "Primary": "Primary", "Product details": "Product details", "Product not found": "Product not found", "Products not found": "Products not found", @@ -153,7 +156,10 @@ "Search": "Search", "Search Orders": "Search Orders", "Search time zones": "Search time zones", + "Secondary": "Secondary", "Select facility": "Select facility", + "Select Facility": "Select Facility", + "Search facilities": "Search facilities", "Select reason": "Select reason", "Selected TimeZone":"Selected TimeZone", "Select a different time zone": "Select a different time zone", diff --git a/src/locales/es.json b/src/locales/es.json index 0c64387fb..8d2543c7f 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -45,6 +45,7 @@ "Failed to print shipping label and packing slip": "Error al imprimir la etiqueta de envío y la hoja de embalaje", "Failed to update product store setting.": "Failed to update product store setting.", "Fetching pickers": "Fetching pickers", + "Fetching facilities": "Fetching facilities", "First name": "Nombre", "Generate packing slips": "Generar documentos de embalaje", "Generate shipping documents": "Generar documentos de envío", @@ -72,6 +73,7 @@ "Mismatch": "Desajuste", "More": "Más", "New notification received.": "Nueva notificación recibida.", + "No facilities found": "No facilities found", "No items found": "No se encontraron artículos", "No inventory details found": "No se encontraron detalles de inventario", "No products found": "No se encontraron productos", @@ -128,6 +130,7 @@ "Pickers successfully replaced in the picklist with the new selections.": "Los recolectores fueron reemplazados exitosamente en la lista de selección con las nuevas selecciones.", "pieces in stock": "piezas en inventario", "Print picklists": "Print picklists", + "Primary": "Primary", "Product details": "Detalles del producto", "Product not found": "Producto no encontrado", "Products not found": "Productos no encontrados", @@ -150,7 +153,10 @@ "Search": "Buscar", "Search Orders": "Buscar pedidos", "Search time zones": "Buscar zonas horarias", + "Secondary": "Secondary", "Select facility": "Seleccionar instalación", + "Select Facility": "Select Facility", + "Search facilities": "Search facilities", "Select reason": "Seleccionar motivo", "Selected TimeZone":"Selected TimeZone", "Select a different time zone": "Select a different time zone", diff --git a/src/locales/ja.json b/src/locales/ja.json index e1eabb157..d1cb23d1c 100644 --- a/src/locales/ja.json +++ b/src/locales/ja.json @@ -45,6 +45,7 @@ "Failed to print shipping label and packing slip": "出荷ラベルと納品書の印刷に失敗しました。", "Failed to update product store setting.":"Failed to update product store setting.", "Fetching pickers": "Fetching pickers", + "Fetching facilities": "Fetching facilities", "First name": "名", "Generate packing slips": "内容明細票の作成", "Generate shipping documents": "出荷書類を生成する", @@ -72,6 +73,7 @@ "Mismatch": "不一致", "More": "もっと見る", "New notification received.": "新しい通知を受信しました。", + "No facilities found": "No facilities found", "No items found": "アイテムが見つかりませんでした", "No inventory details found": "在庫の詳細が見つかりません", "No products found": "商品が見つかりません", @@ -127,6 +129,7 @@ "Pickers successfully replaced in the picklist with the new selections.": "ピッカーは新しい選択によりピックリストで正常に置き換えられました。", "pieces in stock": "在庫あり", "Print picklists": "Print picklists", + "Primary": "Primary", "Product details": "商品詳細", "Product not found": "商品が見つかりません", "Products not found": "商品が見つかりません", @@ -149,6 +152,9 @@ "Search": "検索", "Search Orders": "注文の検索", "Search time zones": "タイムゾーンの検索", + "Secondary": "Secondary", + "Select Facility": "Select Facility", + "Search facilities": "Search facilities", "Select facility": "拠点の検索", "Select reason": "理由を選択", "Select a different time zone": "別のタイムゾーンを選択", diff --git a/src/main.ts b/src/main.ts index 2e6886eab..c1c5e4604 100644 --- a/src/main.ts +++ b/src/main.ts @@ -36,7 +36,7 @@ import { dxpComponents } from '@hotwax/dxp-components' import localeMessages from './locales'; import { login, logout, loader } from '@/utils/user'; import { addNotification, storeClientRegistrationToken } from '@/utils/firebase'; -import { getConfig, fetchGoodIdentificationTypes, getProductIdentificationPref, initialise, setProductIdentificationPref, setUserLocale, getAvailableTimeZones, setUserTimeZone } from '@/adapter'; +import { getConfig, fetchGoodIdentificationTypes, getProductIdentificationPref, getUserFacilities, getUserPreference, initialise, setProductIdentificationPref, setUserLocale, getAvailableTimeZones, setUserTimeZone, setUserPreference } from '@/adapter'; import logger from './logger'; const app = createApp(App) @@ -73,7 +73,10 @@ const app = createApp(App) storeClientRegistrationToken, getAvailableTimeZones, hasPermission, - setUserTimeZone + setUserTimeZone, + getUserFacilities, + setUserPreference, + getUserPreference }); // Filters are removed in Vue 3 and global filter introduced https://v3.vuejs.org/guide/migration/filters.html#global-filters diff --git a/src/store/modules/order/actions.ts b/src/store/modules/order/actions.ts index 3c52c9211..dbdbab778 100644 --- a/src/store/modules/order/actions.ts +++ b/src/store/modules/order/actions.ts @@ -3,7 +3,7 @@ import { ActionTree } from 'vuex' import RootState from '@/store/RootState' import OrderState from './OrderState' import * as types from './mutation-types' -import { showToast } from "@/utils"; +import { showToast, getCurrentFacilityId } from "@/utils"; import { hasError } from '@/adapter' import { translate } from "@hotwax/dxp-components"; import emitter from '@/event-bus' @@ -12,6 +12,7 @@ import { prepareOrderQuery } from "@/utils/solrHelper"; import { getOrderCategory } from "@/utils/order"; import logger from "@/logger"; + const actions: ActionTree ={ async getOrderDetails({ dispatch, commit }, payload ) { @@ -700,7 +701,7 @@ const actions: ActionTree ={ inputFields: { statusId: "SHIPMENT_SHIPPED", shipmentMethodTypeId: "SHIP_TO_STORE", - orderFacilityId: this.state.user.currentFacility.facilityId + orderFacilityId: getCurrentFacilityId() }, viewSize: payload.viewSize ? payload.viewSize : process.env.VUE_APP_VIEW_SIZE, viewIndex: payload.viewIndex ? payload.viewIndex : 0, @@ -786,7 +787,7 @@ const actions: ActionTree ={ inputFields: { statusId: "PICKUP_SCHEDULED", shipmentMethodTypeId: "SHIP_TO_STORE", - orderFacilityId: this.state.user.currentFacility.facilityId + orderFacilityId: getCurrentFacilityId() }, viewSize: payload.viewSize ? payload.viewSize : process.env.VUE_APP_VIEW_SIZE, viewIndex: payload.viewIndex ? payload.viewIndex : 0, @@ -872,7 +873,7 @@ const actions: ActionTree ={ inputFields: { statusId: "SHIPMENT_DELIVERED", shipmentMethodTypeId: "SHIP_TO_STORE", - orderFacilityId: this.state.user.currentFacility.facilityId + orderFacilityId: getCurrentFacilityId() }, viewSize: payload.viewSize ? payload.viewSize : process.env.VUE_APP_VIEW_SIZE, viewIndex: payload.viewIndex ? payload.viewIndex : 0, diff --git a/src/store/modules/stock/actions.ts b/src/store/modules/stock/actions.ts index b70a4d696..dc414220d 100644 --- a/src/store/modules/stock/actions.ts +++ b/src/store/modules/stock/actions.ts @@ -4,23 +4,25 @@ import RootState from '@/store/RootState' import StockState from './StockState' import * as types from './mutation-types' import { hasError } from '@/adapter' -import { showToast } from '@/utils' +import { showToast, getCurrentFacilityId } from '@/utils' import { translate } from "@hotwax/dxp-components"; import logger from '@/logger' import { prepareOrderQuery } from "@/utils/solrHelper"; import { UtilService } from '@/services/UtilService'; + const actions: ActionTree = { async fetchStock({ commit }, { productId }) { + const facilityId = getCurrentFacilityId() try { const payload = { productId: productId, - facilityId: this.state.user.currentFacility.facilityId + facilityId: facilityId } const resp: any = await StockService.getInventoryAvailableByFacility(payload); if (!hasError(resp)) { - commit(types.STOCK_ADD_PRODUCT, { productId: payload.productId, facilityId: this.state.user.currentFacility.facilityId, stock: resp.data }) + commit(types.STOCK_ADD_PRODUCT, { productId: payload.productId, facilityId: facilityId, stock: resp.data }) } else { throw resp.data; } @@ -31,7 +33,7 @@ const actions: ActionTree = { }, async fetchInventoryCount({ commit, state }, { productId }) { - const facilityId = this.state.user.currentFacility.facilityId; + const facilityId = getCurrentFacilityId(); if (state.inventoryInformation[productId] && state.inventoryInformation[productId][facilityId]) { return; } @@ -60,7 +62,7 @@ const actions: ActionTree = { }, async fetchReservedQuantity({ commit, state }, { productId }) { - const facilityId = this.state.user.currentFacility.facilityId; + const facilityId = getCurrentFacilityId(); if (state.inventoryInformation[productId] && state.inventoryInformation[productId][facilityId]?.reservedQuantity) { return; } diff --git a/src/store/modules/stock/getters.ts b/src/store/modules/stock/getters.ts index 3d9a4e392..296fbd042 100644 --- a/src/store/modules/stock/getters.ts +++ b/src/store/modules/stock/getters.ts @@ -1,15 +1,16 @@ import { GetterTree } from 'vuex' import StockState from './StockState' import RootState from '../../RootState' -import store from '@/store' +import { getCurrentFacilityId } from '@/utils' + const getters: GetterTree = { getProductStock: (state, RootState) => (productId: any) => { - const facilityId = store.state.user?.currentFacility?.facilityId + const facilityId = getCurrentFacilityId() return state.products[productId] ? state.products[productId][facilityId] ? state.products[productId][facilityId] : {} : {} }, getInventoryInformation: (state) => (productId: any) => { - const facilityId = store.state.user?.currentFacility?.facilityId + const facilityId = getCurrentFacilityId() return state.inventoryInformation[productId] ? state.inventoryInformation[productId][facilityId] ? state.inventoryInformation[productId][facilityId] : {} : {}; } } diff --git a/src/store/modules/user/UserState.ts b/src/store/modules/user/UserState.ts index 1a911b12c..03dfda70e 100644 --- a/src/store/modules/user/UserState.ts +++ b/src/store/modules/user/UserState.ts @@ -1,7 +1,6 @@ export default interface UserState { token: string; current: any; - currentFacility: object; instanceUrl: string; permissions: any; currentEComStore: any; diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index d2fba4f34..127f07e11 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -5,11 +5,10 @@ import RootState from '@/store/RootState' import store from '@/store'; import UserState from './UserState' import * as types from './mutation-types' -import { showToast } from '@/utils' +import { getCurrentFacilityId, showToast } from '@/utils' import { getNotificationEnumIds, getNotificationUserPrefTypeIds, - getUserFacilities, hasError, logout, resetConfig, @@ -70,8 +69,9 @@ const actions: ActionTree = { //fetching user facilities const isAdminUser = appPermissions.some((appPermission: any) => appPermission?.action === "APP_STOREFULFILLMENT_ADMIN" ); - const baseURL = store.getters['user/getBaseUrl']; - const facilities = await getUserFacilities(token, baseURL, userProfile?.partyId, "PICKUP", isAdminUser); + const facilities = await useUserStore().getUserFacilities(userProfile?.partyId, "PICKUP", isAdminUser) + await useUserStore().getFacilityPreference('SELECTED_FACILITY') + userProfile.facilities = facilities; // removing duplicate records as a single user can be associated with a facility by multiple roles. @@ -81,8 +81,7 @@ const actions: ActionTree = { return uniqueFacilities }, []); // TODO Use a separate API for getting facilities, this should handle user like admin accessing the app - const currentFacility = userProfile.facilities.length > 0 ? userProfile.facilities[0] : {}; - const currentEComStore = await UserService.getCurrentEComStore(token, currentFacility?.facilityId); + const currentEComStore = await UserService.getCurrentEComStore(token, getCurrentFacilityId()); /* ---- Guard clauses ends here --- */ @@ -94,7 +93,6 @@ const actions: ActionTree = { // TODO user single mutation commit(types.USER_INFO_UPDATED, userProfile); - commit(types.USER_CURRENT_FACILITY_UPDATED, currentFacility); commit(types.USER_CURRENT_ECOM_STORE_UPDATED, currentEComStore) commit(types.USER_PERMISSIONS_UPDATED, appPermissions); commit(types.USER_TOKEN_CHANGED, { newToken: token }) @@ -173,21 +171,15 @@ const actions: ActionTree = { }, /** - * update current facility information + * run after updating current facility */ - async setFacility ({ commit, dispatch, state }, payload) { + async setFacility({ commit, dispatch }, facilityId) { const token = store.getters['user/getUserToken']; - let facility = payload.facility; - if(!facility && state.current?.facilities) { - facility = state.current.facilities.find((facility: any) => facility.facilityId === payload.facilityId); - } // clearing the orders state whenever changing the facility dispatch("order/clearOrders", null, {root: true}) dispatch("product/clearProducts", null, {root: true}) - commit(types.USER_CURRENT_FACILITY_UPDATED, facility); - const eComStore = await UserService.getCurrentEComStore(token, facility?.facilityId); + const eComStore = await UserService.getCurrentEComStore(token, facilityId); commit(types.USER_CURRENT_ECOM_STORE_UPDATED, eComStore) - await useProductIdentificationStore().getIdentificationPref(eComStore?.productStoreId) }, /** @@ -292,8 +284,8 @@ const actions: ActionTree = { async fetchNotificationPreferences({ commit, state }) { let resp = {} as any - const facilityId = (state.currentFacility as any).facilityId let notificationPreferences = [], enumerationResp = [], userPrefIds = [] as any + try { resp = await getNotificationEnumIds(process.env.VUE_APP_NOTIF_ENUM_TYPE_ID) enumerationResp = resp.docs @@ -306,7 +298,7 @@ const actions: ActionTree = { // data and getNotificationUserPrefTypeIds fails or returns empty response (all disbaled) if (enumerationResp.length) { notificationPreferences = enumerationResp.reduce((notifactionPref: any, pref: any) => { - const userPrefTypeIdToSearch = generateTopicName(facilityId, pref.enumId) + const userPrefTypeIdToSearch = generateTopicName(getCurrentFacilityId(), pref.enumId) notifactionPref.push({ ...pref, isEnabled: userPrefIds.includes(userPrefTypeIdToSearch) }) return notifactionPref }, []) diff --git a/src/store/modules/user/getters.ts b/src/store/modules/user/getters.ts index 95c206363..929990a1a 100644 --- a/src/store/modules/user/getters.ts +++ b/src/store/modules/user/getters.ts @@ -20,9 +20,6 @@ const getters: GetterTree = { getUserProfile (state) { return state.current }, - getCurrentFacility (state){ - return state.currentFacility - }, getInstanceUrl (state) { const baseUrl = process.env.VUE_APP_BASE_URL; return baseUrl ? baseUrl : state.instanceUrl; diff --git a/src/store/modules/user/index.ts b/src/store/modules/user/index.ts index 45a5cd6ce..c258e2920 100644 --- a/src/store/modules/user/index.ts +++ b/src/store/modules/user/index.ts @@ -10,7 +10,6 @@ const userModule: Module = { state: { token: '', current: {}, - currentFacility: {}, instanceUrl: '', currentEComStore: {}, partialOrderRejectionConfig: {}, diff --git a/src/store/modules/user/mutation-types.ts b/src/store/modules/user/mutation-types.ts index 1342b50ff..d091504e4 100644 --- a/src/store/modules/user/mutation-types.ts +++ b/src/store/modules/user/mutation-types.ts @@ -2,7 +2,6 @@ export const SN_USER = 'user' 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_CURRENT_FACILITY_UPDATED = SN_USER + '/CURRENT_FACILITY_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_PERMISSIONS_UPDATED = SN_USER + '/PERMISSIONS_UPDATED' diff --git a/src/store/modules/user/mutations.ts b/src/store/modules/user/mutations.ts index 287960439..8122a936f 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.currentFacility = {} state.permissions = [] state.allNotificationPrefs = [], state.bopisProductStoreSettings = {} @@ -17,9 +16,6 @@ const mutations: MutationTree = { [types.USER_INFO_UPDATED] (state, payload) { state.current = payload }, - [types.USER_CURRENT_FACILITY_UPDATED] (state, payload) { - state.currentFacility = payload; - }, [types.USER_INSTANCE_URL_UPDATED] (state, payload) { state.instanceUrl = payload; }, diff --git a/src/utils/index.ts b/src/utils/index.ts index 3dfec677e..2ec41f243 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,6 +1,6 @@ import { toastController } from '@ionic/vue'; import { Plugins } from '@capacitor/core'; -import { translate } from '@hotwax/dxp-components' +import { translate, useUserStore } from '@hotwax/dxp-components' import { DateTime } from "luxon"; // TODO Use separate files for specific utilities @@ -73,4 +73,9 @@ const formatPhoneNumber = (countryCode: string | null, areaCode: string | null, } } -export { copyToClipboard, showToast, handleDateTimeInput, getFeature, formatPhoneNumber } +const getCurrentFacilityId = () => { + const currentFacility: any = useUserStore().getCurrentFacility; + return currentFacility?.facilityId +} + +export { copyToClipboard, showToast, handleDateTimeInput, getFeature, formatPhoneNumber, getCurrentFacilityId } diff --git a/src/views/OrderDetail.vue b/src/views/OrderDetail.vue index 7b9cff6c4..8a19f554c 100644 --- a/src/views/OrderDetail.vue +++ b/src/views/OrderDetail.vue @@ -257,7 +257,7 @@ import { DateTime } from "luxon"; import { api, hasError } from '@/adapter'; import { OrderService } from "@/services/OrderService"; import RejectOrderModal from "@/components/RejectOrderModal.vue"; -import { getProductIdentificationValue, translate, useProductIdentificationStore } from "@hotwax/dxp-components"; +import { getProductIdentificationValue, translate, useProductIdentificationStore, useUserStore } from "@hotwax/dxp-components"; import EditPickerModal from "@/components/EditPickerModal.vue"; import emitter from '@/event-bus' import logger from "@/logger"; @@ -312,7 +312,6 @@ export default defineComponent({ computed: { ...mapGetters({ order: "order/getCurrent", - currentFacility: 'user/getCurrentFacility', partialOrderRejectionConfig: 'user/getPartialOrderRejectionConfig', getPaymentMethodDesc: 'util/getPaymentMethodDesc', getStatusDesc: 'util/getStatusDesc', @@ -379,7 +378,7 @@ export default defineComponent({ }, async getOrderDetail(orderId: any, orderPartSeqId: any, orderType: any) { const payload = { - facilityId: this.currentFacility.facilityId, + facilityId: this.currentFacility?.facilityId, orderId, orderPartSeqId } @@ -394,7 +393,7 @@ export default defineComponent({ return rejectOrderModal.present(); }, async readyForPickup(order: any, part: any) { - if(this.getBopisProductStoreSettings('ENABLE_TRACKING') && order.isPicked !== 'Y') return this.assignPicker(order, part, this.currentFacility.facilityId); + if(this.getBopisProductStoreSettings('ENABLE_TRACKING') && order.isPicked !== 'Y') return this.assignPicker(order, part, this.currentFacility?.facilityId); const pickup = part?.shipmentMethodEnum?.shipmentMethodEnumId === 'STOREPICKUP'; const header = pickup ? translate('Ready for pickup') : translate('Ready to ship'); const message = pickup ? translate('An email notification will be sent to that their order is ready for pickup. This order will also be moved to the packed orders tab.', { customerName: order.customer.name, space: '

' }) : ''; @@ -412,7 +411,7 @@ export default defineComponent({ if(!pickup) { this.packShippingOrders(order, part); } else { - this.store.dispatch('order/packShipGroupItems', {order, part, facilityId: this.currentFacility.facilityId}) + this.store.dispatch('order/packShipGroupItems', {order, part, facilityId: this.currentFacility?.facilityId}) } } }] @@ -544,8 +543,10 @@ export default defineComponent({ setup() { const store = useStore(); const router = useRouter(); + const userStore = useUserStore() const productIdentificationStore = useProductIdentificationStore(); let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref) + let currentFacility: any = computed(() => userStore.getCurrentFacility) return { Actions, @@ -560,6 +561,7 @@ export default defineComponent({ checkmarkCircleOutline, checkmarkOutline, cubeOutline, + currentFacility, getProductIdentificationValue, giftOutline, getFeature, diff --git a/src/views/Orders.vue b/src/views/Orders.vue index b95a41137..99c34ce84 100644 --- a/src/views/Orders.vue +++ b/src/views/Orders.vue @@ -194,7 +194,7 @@ import { IonToolbar, modalController } from "@ionic/vue"; -import { defineComponent, ref } from "vue"; +import { defineComponent, ref, computed } from "vue"; import ProductListItem from '@/components/ProductListItem.vue' import { swapVerticalOutline, @@ -210,7 +210,7 @@ import { copyToClipboard, showToast } from '@/utils' import { DateTime } from 'luxon'; import emitter from "@/event-bus" import { api, hasError } from '@/adapter'; -import { translate } from "@hotwax/dxp-components"; +import { translate, useUserStore } from "@hotwax/dxp-components"; import AssignPickerModal from "./AssignPickerModal.vue"; import { OrderService } from "@/services/OrderService"; import { UserService } from "@/services/UserService"; @@ -252,7 +252,6 @@ export default defineComponent({ orders: 'order/getOpenOrders', packedOrders: 'order/getPackedOrders', completedOrders: 'order/getCompletedOrders', - currentFacility: 'user/getCurrentFacility', isPackedOrdersScrollable: 'order/isPackedOrdersScrollable', isOpenOrdersScrollable: 'order/isOpenOrdersScrollable', isCompletedOrdersScrollable: 'order/isCompletedOrdersScrollable', @@ -336,20 +335,19 @@ export default defineComponent({ async getPickupOrders (vSize?: any, vIndex?: any) { const viewSize = vSize ? vSize : process.env.VUE_APP_VIEW_SIZE; const viewIndex = vIndex ? vIndex : 0; - - await this.store.dispatch("order/getOpenOrders", { viewSize, viewIndex, queryString: this.queryString, facilityId: this.currentFacility.facilityId }); + await this.store.dispatch("order/getOpenOrders", { viewSize, viewIndex, queryString: this.queryString, facilityId: this.currentFacility?.facilityId }); }, async getPackedOrders (vSize?: any, vIndex?: any) { const viewSize = vSize ? vSize : process.env.VUE_APP_VIEW_SIZE; const viewIndex = vIndex ? vIndex : 0; - await this.store.dispatch("order/getPackedOrders", { viewSize, viewIndex, queryString: this.queryString, facilityId: this.currentFacility.facilityId }); + await this.store.dispatch("order/getPackedOrders", { viewSize, viewIndex, queryString: this.queryString, facilityId: this.currentFacility?.facilityId }); }, async getCompletedOrders (vSize?: any, vIndex?: any) { const viewSize = vSize ? vSize : process.env.VUE_APP_VIEW_SIZE; const viewIndex = vIndex ? vIndex : 0; - await this.store.dispatch("order/getCompletedOrders", { viewSize, viewIndex, queryString: this.queryString, facilityId: this.currentFacility.facilityId }); + await this.store.dispatch("order/getCompletedOrders", { viewSize, viewIndex, queryString: this.queryString, facilityId: this.currentFacility?.facilityId }); }, enableScrolling() { const parentElement = (this as any).$refs.contentRef.$el @@ -391,7 +389,7 @@ export default defineComponent({ } }, async readyForPickup (order: any, part: any) { - if(this.getBopisProductStoreSettings('ENABLE_TRACKING') && order.isPicked !== 'Y') return this.assignPicker(order, part, this.currentFacility.facilityId); + if(this.getBopisProductStoreSettings('ENABLE_TRACKING') && order.isPicked !== 'Y') return this.assignPicker(order, part, this.currentFacility?.facilityId); const pickup = part.shipmentMethodEnum?.shipmentMethodEnumId === 'STOREPICKUP'; const header = pickup ? translate('Ready for pickup') : translate('Ready to ship'); const message = pickup ? translate('An email notification will be sent to that their order is ready for pickup. This order will also be moved to the packed orders tab.', { customerName: order.customer.name, space: '

'}) : ''; @@ -409,7 +407,7 @@ export default defineComponent({ if(!pickup) { this.packShippingOrders(order, part); } else { - this.store.dispatch('order/packShipGroupItems', {order, part, facilityId: this.currentFacility.facilityId}) + this.store.dispatch('order/packShipGroupItems', {order, part, facilityId: this.currentFacility?.facilityId}) } } }] @@ -598,11 +596,14 @@ export default defineComponent({ const router = useRouter(); const store = useStore(); const segmentSelected = ref('open'); - + const userStore = useUserStore() + let currentFacility: any = computed(() => userStore.getCurrentFacility) + return { Actions, callOutline, copyToClipboard, + currentFacility, hasPermission, notificationsOutline, mailOutline, diff --git a/src/views/ProductDetail.vue b/src/views/ProductDetail.vue index 7a9ba5bfb..1cba9d861 100644 --- a/src/views/ProductDetail.vue +++ b/src/views/ProductDetail.vue @@ -166,7 +166,7 @@ import { getFeature, showToast } from "@/utils"; import { hasError } from '@/adapter' import { sortSizes } from '@/apparel-sorter'; import OtherStoresInventoryModal from "./OtherStoresInventoryModal.vue"; -import { DxpShopifyImg, getProductIdentificationValue, translate, useProductIdentificationStore } from "@hotwax/dxp-components"; +import { DxpShopifyImg, getProductIdentificationValue, translate, useProductIdentificationStore, useUserStore } from "@hotwax/dxp-components"; import logger from "@/logger"; export default defineComponent({ @@ -210,7 +210,6 @@ export default defineComponent({ computed: { ...mapGetters({ product: "product/getCurrent", - currentFacility: 'user/getCurrentFacility', currency: 'user/getCurrency', getProductStock: 'stock/getProductStock', getInventoryInformation: 'stock/getInventoryInformation', @@ -228,7 +227,7 @@ export default defineComponent({ methods: { //For fetching all the orders for this product & facility. async getOrderDetails() { - await this.store.dispatch("order/getOrderDetails", { viewSize: 200, facilityId: this.currentFacility.facilityId, productId: this.currentVariant.productId }); + await this.store.dispatch("order/getOrderDetails", { viewSize: 200, facilityId: this.currentFacility?.facilityId, productId: this.currentVariant.productId }); }, async applyFeature(feature: string, type: string) { if(type === 'color') this.selectedColor = feature; @@ -295,7 +294,7 @@ export default defineComponent({ if (resp.status === 200 && !hasError(resp) && resp.data.docs.length) { resp.data.docs.map((storeInventory: any) => { if(storeInventory.atp) { - const isCurrentStore = storeInventory.facilityId === this.currentFacility.facilityId; + const isCurrentStore = storeInventory.facilityId === this.currentFacility?.facilityId; if (isCurrentStore) this.currentStoreInventory = storeInventory.atp; if (storeInventory.facilityTypeId === 'WAREHOUSE') { this.warehouseInventory += storeInventory.atp @@ -322,10 +321,13 @@ export default defineComponent({ }, setup() { const store = useStore(); + const userStore = useUserStore() const productIdentificationStore = useProductIdentificationStore(); let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref) + let currentFacility: any = computed(() => userStore.getCurrentFacility) return { + currentFacility, getProductIdentificationValue, productIdentificationPref, store, diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 3d43cab68..2a054d013 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -35,23 +35,7 @@
- - - - - {{ translate("Facility") }} - - - - {{ translate('Specify which facility you want to operate from. Order, inventory and other configuration data will be specific to the facility you select.') }} - - - - {{ facility.facilityName }} - - - - + @@ -201,7 +185,7 @@ import { IonToggle, IonToolbar } from '@ionic/vue'; -import { defineComponent } from 'vue'; +import { defineComponent, computed } from 'vue'; import { codeWorkingOutline, ellipsisVertical, @@ -217,7 +201,7 @@ import { DateTime } from 'luxon'; import { UserService } from '@/services/UserService' import { showToast } from '@/utils'; import { hasError, removeClientRegistrationToken, subscribeTopic, unsubscribeTopic } from '@/adapter' -import { initialiseFirebaseApp, translate } from "@hotwax/dxp-components"; +import { initialiseFirebaseApp, translate, useUserStore } from "@hotwax/dxp-components"; import { Actions, hasPermission } from '@/authorization' import { addNotification, generateTopicName, isFcmConfigured, storeClientRegistrationToken } from "@/utils/firebase"; import emitter from "@/event-bus" @@ -266,7 +250,6 @@ export default defineComponent({ computed: { ...mapGetters({ userProfile: 'user/getUserProfile', - currentFacility: 'user/getCurrentFacility', currentEComStore: 'user/getCurrentEComStore', partialOrderRejectionConfig: 'user/getPartialOrderRejectionConfig', firebaseDeviceId: 'user/getFirebaseDeviceId', @@ -293,15 +276,10 @@ export default defineComponent({ await this.store.dispatch('user/fetchNotificationPreferences') }, methods: { - async setFacility (event: any) { - if (this.userProfile) { - await this.store.dispatch('user/setFacility', { - 'facilityId': event.detail.value - }); - await this.store.dispatch('user/fetchNotificationPreferences') - } + async updateFacility(facility: any) { + await this.store.dispatch('user/setFacility', facility?.facilityId); + await this.store.dispatch('user/fetchNotificationPreferences') }, - async timeZoneUpdated(tzId: string) { await this.store.dispatch("user/setUserTimeZone", tzId) }, @@ -424,7 +402,7 @@ export default defineComponent({ } emitter.emit('presentLoader', { backdropDismiss: false }) - const facilityId = (this.currentFacility as any).facilityId + const facilityId = this.currentFacility?.facilityId const topicName = generateTopicName(facilityId, enumId) const notificationPref = this.notificationPrefs.find((pref: any) => pref.enumId === enumId) @@ -481,9 +459,12 @@ export default defineComponent({ setup () { const store = useStore(); const router = useRouter(); + const userStore = useUserStore() + let currentFacility: any = computed(() => userStore.getCurrentFacility) return { Actions, + currentFacility, ellipsisVertical, hasPermission, personCircleOutline, diff --git a/src/views/ShipToStoreOrders.vue b/src/views/ShipToStoreOrders.vue index 4e8e84f56..97a35eb4f 100644 --- a/src/views/ShipToStoreOrders.vue +++ b/src/views/ShipToStoreOrders.vue @@ -122,7 +122,7 @@ import { IonTitle, IonToolbar, } from "@ionic/vue"; -import { defineComponent, ref } from "vue"; +import { defineComponent, ref, computed } from "vue"; import ProductListItem from '@/components/ProductListItem.vue' import { mailOutline } from "ionicons/icons"; import { mapGetters, useStore } from 'vuex' @@ -133,7 +133,7 @@ import { DateTime } from 'luxon'; import emitter from "@/event-bus" import { Actions, hasPermission } from '@/authorization' import { OrderService } from "@/services/OrderService"; -import { translate } from "@hotwax/dxp-components"; +import { translate, useUserStore } from "@hotwax/dxp-components"; import logger from "@/logger"; export default defineComponent({ @@ -168,7 +168,6 @@ export default defineComponent({ }, computed: { ...mapGetters({ - currentFacility: 'user/getCurrentFacility', incomingOrders: 'order/getShipToStoreIncomingOrders', readyForPickupOrders: 'order/getShipToStoreReadyForPickupOrders', completedOrders: 'order/getShipToStoreCompletedOrders', @@ -201,19 +200,19 @@ export default defineComponent({ const viewSize = vSize ? vSize : process.env.VUE_APP_VIEW_SIZE; const viewIndex = vIndex ? vIndex : 0; - await this.store.dispatch("order/getShipToStoreIncomingOrders", { viewSize, viewIndex, queryString: this.queryString, facilityId: this.currentFacility.facilityId }); + await this.store.dispatch("order/getShipToStoreIncomingOrders", { viewSize, viewIndex, queryString: this.queryString, facilityId: this.currentFacility?.facilityId }); }, async getReadyForPickupOrders (vSize?: any, vIndex?: any) { const viewSize = vSize ? vSize : process.env.VUE_APP_VIEW_SIZE; const viewIndex = vIndex ? vIndex : 0; - await this.store.dispatch("order/getShipToStoreReadyForPickupOrders", { viewSize, viewIndex, queryString: this.queryString, facilityId: this.currentFacility.facilityId }); + await this.store.dispatch("order/getShipToStoreReadyForPickupOrders", { viewSize, viewIndex, queryString: this.queryString, facilityId: this.currentFacility?.facilityId }); }, async getCompletedOrders (vSize?: any, vIndex?: any) { const viewSize = vSize ? vSize : process.env.VUE_APP_VIEW_SIZE; const viewIndex = vIndex ? vIndex : 0; - await this.store.dispatch("order/getShipToStoreCompletedOrders", { viewSize, viewIndex, queryString: this.queryString, facilityId: this.currentFacility.facilityId }); + await this.store.dispatch("order/getShipToStoreCompletedOrders", { viewSize, viewIndex, queryString: this.queryString, facilityId: this.currentFacility?.facilityId }); }, enableScrolling() { const parentElement = (this as any).$refs.contentRef.$el @@ -420,11 +419,14 @@ export default defineComponent({ setup () { const router = useRouter(); const store = useStore(); + const userStore = useUserStore() const segmentSelected = ref('incoming'); + let currentFacility: any = computed(() => userStore.getCurrentFacility) return { Actions, copyToClipboard, + currentFacility, hasPermission, mailOutline, router,