diff --git a/package-lock.json b/package-lock.json index db8a8747..c3b46686 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,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", @@ -2798,9 +2798,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 202e3e50..75b9aba1 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,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 6cd94c76..657e0939 100644 --- a/src/adapter/index.ts +++ b/src/adapter/index.ts @@ -1,6 +1,6 @@ -import { api, client, getConfig, getNotificationEnumIds, getNotificationUserPrefTypeIds, getProductIdentificationPref, fetchGoodIdentificationTypes, getUserFacilities, hasError, initialise, logout, removeClientRegistrationToken, resetConfig, setProductIdentificationPref, setUserLocale, storeClientRegistrationToken, - subscribeTopic, unsubscribeTopic, updateInstanceUrl, updateToken, setUserTimeZone, getAvailableTimeZones } from '@hotwax/oms-api' +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' export { api, @@ -11,6 +11,7 @@ export { getProductIdentificationPref, fetchGoodIdentificationTypes, getUserFacilities, + getUserPreference, hasError, initialise, logout, @@ -24,5 +25,6 @@ export { updateInstanceUrl, updateToken, setUserTimeZone, + setUserPreference, getAvailableTimeZones } \ No newline at end of file diff --git a/src/components/DownloadRejectedOrdersModal.vue b/src/components/DownloadRejectedOrdersModal.vue index 3ea8f213..10cb2e9c 100644 --- a/src/components/DownloadRejectedOrdersModal.vue +++ b/src/components/DownloadRejectedOrdersModal.vue @@ -72,7 +72,7 @@ } from '@ionic/vue'; import { computed, defineComponent } from 'vue'; import { closeOutline, cloudDownloadOutline} from 'ionicons/icons'; - import { getProductIdentificationValue, translate, useProductIdentificationStore } from '@hotwax/dxp-components'; + import { getProductIdentificationValue, translate, useProductIdentificationStore, useUserStore } from '@hotwax/dxp-components'; import { mapGetters, useStore } from 'vuex'; import { escapeSolrSpecialChars, prepareSolrQuery } from '@/utils/solrHelper' import { RejectionService } from '@/services/RejectionService' @@ -136,8 +136,7 @@ computed: { ...mapGetters({ getProduct: 'product/getProduct', - rejectedOrders: 'rejection/getRejectedOrders', - currentFacility: 'user/getCurrentFacility', + rejectedOrders: 'rejection/getRejectedOrders' }) }, methods: { @@ -297,8 +296,10 @@ }, setup() { const store = useStore() + const userStore = useUserStore() const productIdentificationStore = useProductIdentificationStore(); let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref) + let currentFacility: any = computed(() => userStore.getCurrentFacility) return { @@ -308,6 +309,7 @@ productIdentificationPref, store, translate, + currentFacility } } }); diff --git a/src/components/Menu.vue b/src/components/Menu.vue index e6475670..5138ea9d 100644 --- a/src/components/Menu.vue +++ b/src/components/Menu.vue @@ -50,7 +50,7 @@ import { arrowBackOutline, backspaceOutline, mailUnreadOutline, mailOpenOutline, import { useStore } from "@/store"; import { useRouter } from "vue-router"; import { hasPermission } from "@/authorization"; -import { translate } from '@hotwax/dxp-components'; +import { translate, useUserStore } from '@hotwax/dxp-components'; export default defineComponent({ name: "Menu", @@ -70,7 +70,6 @@ export default defineComponent({ computed: { ...mapGetters({ isUserAuthenticated: 'user/isUserAuthenticated', - currentFacility: 'user/getCurrentFacility', }) }, methods: { @@ -81,6 +80,8 @@ export default defineComponent({ setup() { const store = useStore(); const router = useRouter(); + const userStore = useUserStore() + let currentFacility: any = computed(() => userStore.getCurrentFacility) const appPages = [ { @@ -189,6 +190,7 @@ export default defineComponent({ appPages, backspaceOutline, checkmarkDoneOutline, + currentFacility, hasPermission, arrowBackOutline, mailUnreadOutline, diff --git a/src/components/NotificationPreferenceModal.vue b/src/components/NotificationPreferenceModal.vue index d7806673..28f85dd0 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 { defineComponent, computed } 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/TransferOrderFilters.vue b/src/components/TransferOrderFilters.vue index dda0935d..c231ae70 100644 --- a/src/components/TransferOrderFilters.vue +++ b/src/components/TransferOrderFilters.vue @@ -46,14 +46,14 @@ import { IonTitle, IonToolbar } from "@ionic/vue"; -import { defineComponent } from "vue"; +import { defineComponent, computed } from "vue"; import { albumsOutline, banOutline, barChartOutline, calendarNumberOutline, checkmarkDoneOutline, closeOutline, filterOutline, iceCreamOutline, libraryOutline, pulseOutline, settings, shirtOutline, ticketOutline } from "ionicons/icons"; import { mapGetters, useStore } from 'vuex' import { escapeSolrSpecialChars, prepareOrderQuery } from '@/utils/solrHelper'; import { UtilService } from '@/services/UtilService'; import { hasError } from '@/adapter'; import logger from '@/logger'; -import { translate } from '@hotwax/dxp-components'; +import { translate, useUserStore } from '@hotwax/dxp-components'; export default defineComponent({ name: "TransferOrderFilters", @@ -77,7 +77,6 @@ export default defineComponent({ }, computed: { ...mapGetters({ - currentFacility: 'user/getCurrentFacility', transferOrders: 'transferorder/getTransferOrders', getStatusDesc: 'util/getStatusDesc', getShipmentMethodDesc: 'util/getShipmentMethodDesc', @@ -126,7 +125,7 @@ export default defineComponent({ filters: { '-orderStatusId': { value: 'ORDER_CREATED' }, orderTypeId: { value: 'TRANSFER_ORDER' }, - facilityId: { value: escapeSolrSpecialChars(this.currentFacility.facilityId) }, + facilityId: { value: escapeSolrSpecialChars(this.currentFacility?.facilityId) }, productStoreId: { value: this.currentEComStore.productStoreId } }, facet: { @@ -172,7 +171,9 @@ export default defineComponent({ }, setup() { const store = useStore(); - + const userStore = useUserStore() + let currentFacility: any = computed(() => userStore.getCurrentFacility) + return { albumsOutline, banOutline, @@ -180,6 +181,7 @@ export default defineComponent({ calendarNumberOutline, checkmarkDoneOutline, closeOutline, + currentFacility, filterOutline, iceCreamOutline, libraryOutline, diff --git a/src/locales/en.json b/src/locales/en.json index 67a9b2fe..b7a60cc6 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -214,6 +214,7 @@ "Failed to update shipment method detail.": "Failed to update shipment method detail.", "Failed to update tracking code settings.": "Failed to update tracking code settings.", "Failed to update variance type.": "Failed to update variance type.", + "Fetching facilities": "Fetching facilities", "Fetching gift card info.": "Fetching gift card info.", "Fetching time zones": "Fetching time zones", "Fetching order information...": "Fetching order information...", @@ -305,6 +306,7 @@ "No carrier found.": "No carrier found.", "No data available": "No data available", "No data found": "No data found", + "No facilities found": "No facilities found", "No rejection reasons found.": "No rejection reasons found.", "No shipments have been shipped yet": "No shipments have been shipped yet", "No shipping label error received from carrier.": "No shipping label error received from carrier", @@ -501,6 +503,8 @@ "Select an issue": "Select an issue", "Select CSV": "Select CSV", "Select facility": "Select facility", + "Select Facility": "Select Facility", + "Search facilities": "Search facilities", "Select store": "Select store", "Select the column for the following information in the uploaded CSV.": "Select the column for the following information in the uploaded CSV.", "Select the fields you want to include in your export": "Select the fields you want to include in your export", diff --git a/src/locales/es.json b/src/locales/es.json index 7adbf1fd..ed4abc6c 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -211,6 +211,7 @@ "Failed to update shipment method detail.": "Error al actualziar detalles metodo de envio.", "Failed to update tracking code settings.": "Error al actualizar la configuracion del codigo de seguimiento.", "Failed to update variance type.": "Error al actualizar el tipo de variante.", + "Fetching facilities": "Fetching facilities", "Fetching gift card info.": "Obteniendo información de gift card.", "Fetching order information...": "Obteniendo información del pedido...", "Fetching pickers": "Obteniendo recolectores", @@ -304,6 +305,7 @@ "No channels found": "No se encontraron canales", "No data available": "¡No hay datos disponibles!", "No data found": "No se encontro dato", + "No facilities found": "No facilities found", "No rejection reasons found.": "No se encontro razon de rechazo.", "No shipments have been shipped yet": "Aún no se han enviado envíos", "No shipping label error received from carrier": "No se encontraron datos.", @@ -498,6 +500,8 @@ "Select an issue": "Selecciona un problema", "Select CSV": "Seleccionar CSV", "Select facility": "Seleccionar instalación", + "Select Facility": "Select Facility", + "Search facilities": "Search facilities", "Select store": "Seleccionar tienda", "Select the column for the following information in the uploaded CSV.": "Selecciona la columna para la siguiente información en el CSV cargado.", "Select the fields you want to include in your export": "Selecciona los campos que deseas incluir en tu exportación", diff --git a/src/locales/ja.json b/src/locales/ja.json index 5cad6757..e93d1e90 100644 --- a/src/locales/ja.json +++ b/src/locales/ja.json @@ -214,6 +214,7 @@ "Failed to update shipment method detail.": "Failed to update shipment method detail.", "Failed to update tracking code settings.": "追跡コード設定の更新に失敗しました。", "Failed to update variance type.": "変動タイプの更新に失敗しました。", + "Fetching facilities": "Fetching facilities", "Fetching gift card info.": "Fetching gift card info.", "Fetching time zones": "タイムゾーンの取得中", "Fetching order information...": "注文情報の取得中...", @@ -304,6 +305,7 @@ "No carrier found.": "キャリアが見つかりません。", "No data available": "データがありません", "No data found": "何もデータが見つかりませんでした", + "No facilities found": "No facilities found", "No rejection reasons found.": "拒否理由が見つかりません。", "No shipments have been shipped yet": "まだ出荷された出荷はありません", "No shipping label error received from carrier.": "キャリアから配送ラベルエラーは受信されていません", @@ -498,6 +500,8 @@ "Select an issue": "問題を選択", "Select CSV": "CSVを選択", "Select facility": "施設を選択", + "Select Facility": "Select Facility", + "Search facilities": "Search facilities", "Select store": "ストアを選択", "Select the column for the following information in the uploaded CSV.": "アップロードされたCSV内の次の情報に対する列を選択。", "Select the fields you want to include in your export": "エクスポートに含めるフィールドを選択", diff --git a/src/main.ts b/src/main.ts index 0710cd4a..aa6a61e4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -31,8 +31,8 @@ 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, initialise, setProductIdentificationPref, setUserLocale, setUserTimeZone, - getAvailableTimeZones } from './adapter'; +import { getConfig, fetchGoodIdentificationTypes, getProductIdentificationPref, getUserFacilities, getUserPreference, initialise, setProductIdentificationPref, setUserLocale, getAvailableTimeZones, setUserTimeZone, + setUserPreference } from './adapter'; import localeMessages from '@/locales'; import { addNotification, storeClientRegistrationToken } from '@/utils/firebase'; @@ -70,6 +70,9 @@ const app = createApp(App) setUserTimeZone, storeClientRegistrationToken, getAvailableTimeZones, + getUserFacilities, + setUserPreference, + getUserPreference, hasPermission }); diff --git a/src/services/UtilService.ts b/src/services/UtilService.ts index 9fd09992..7757f694 100644 --- a/src/services/UtilService.ts +++ b/src/services/UtilService.ts @@ -1,7 +1,7 @@ import { api, hasError } from '@/adapter'; import logger from '@/logger'; import store from '@/store'; -import { isPdf } from '@/utils'; +import { isPdf, getCurrentFacilityId } from '@/utils'; const fetchShipmentMethods = async (query: any): Promise => { return api({ @@ -37,7 +37,7 @@ const findShipmentIdsForOrders = async(picklistBinIds: Array, orderIds: "primaryOrderId_op": "in", "picklistBinId": picklistBinIds, "picklistBinId_op": "in", - "originFacilityId": store.state.user.currentFacility.facilityId, + "originFacilityId": getCurrentFacilityId(), "statusId": statusId, "statusId_op": "in" }, diff --git a/src/store/modules/carrier/actions.ts b/src/store/modules/carrier/actions.ts index 02dafaef..137da673 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 } from '@/utils'; +import { showToast, isValidCarrierCode, isValidDeliveryDays, getCurrentFacilityId } from '@/utils'; const actions: ActionTree = { @@ -358,14 +358,14 @@ const actions: ActionTree = { async fetchFacilityCarriers({ state, commit }, payload) { let facilityCarriers = [] as any; let viewIndex = 0, resp, docCount = 0; - + try { do { const params = { "entityName": "FacilityAndParty", "inputFields": { "roleTypeId": "CARRIER", - "facilityId": this.state.user.currentFacility.facilityId + "facilityId": getCurrentFacilityId() }, "fieldList": ["facilityId", "partyId", "firstName", "lastName", "groupName", "roleTypeId", "fromDate"], "noConditionFind": "Y", diff --git a/src/store/modules/order/actions.ts b/src/store/modules/order/actions.ts index 718d7f17..5517cf84 100644 --- a/src/store/modules/order/actions.ts +++ b/src/store/modules/order/actions.ts @@ -9,6 +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' const actions: ActionTree = { async fetchInProgressOrdersAdditionalInformation({ commit, dispatch, state }, payload = { viewIndex: 0 }) { @@ -171,7 +172,7 @@ const actions: ActionTree = { } try { - const shipmentbatches = await Promise.all(requestParams.map((params) => OrderService.fetchShipments(params.picklistBinIds, params.orderIds, this.state.user.currentFacility.facilityId))) + const shipmentbatches = await Promise.all(requestParams.map((params) => OrderService.fetchShipments(params.picklistBinIds, params.orderIds, getCurrentFacilityId()))) // TODO simplify below logic by returning shipments list const shipments = shipmentbatches.flat(); @@ -324,7 +325,7 @@ const actions: ActionTree = { picklistItemStatusId: { value: 'PICKITEM_PENDING' }, '-fulfillmentStatus': { value: ['Rejected', 'Cancelled'] }, '-shipmentMethodTypeId': { value: 'STOREPICKUP' }, - facilityId: { value: escapeSolrSpecialChars(this.state.user.currentFacility.facilityId) }, + facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) }, productStoreId: { value: this.state.user.currentEComStore.productStoreId } } } @@ -418,7 +419,7 @@ const actions: ActionTree = { '-fulfillmentStatus': { value: ['Cancelled', 'Rejected']}, orderStatusId: { value: 'ORDER_APPROVED' }, orderTypeId: { value: 'SALES_ORDER' }, - facilityId: { value: escapeSolrSpecialChars(this.state.user.currentFacility.facilityId) }, + facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) }, productStoreId: { value: this.state.user.currentEComStore.productStoreId } } } @@ -489,7 +490,7 @@ const actions: ActionTree = { filters: { picklistItemStatusId: { value: '(PICKITEM_PICKED OR (PICKITEM_COMPLETED AND itemShippedDate: [NOW/DAY TO NOW/DAY+1DAY]))' }, '-shipmentMethodTypeId': { value: 'STOREPICKUP' }, - facilityId: { value: escapeSolrSpecialChars(this.state.user.currentFacility.facilityId) }, + facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) }, productStoreId: { value: this.state.user.currentEComStore.productStoreId } } } @@ -772,7 +773,7 @@ const actions: ActionTree = { '-fulfillmentStatus': { value: ['Cancelled', 'Rejected']}, orderStatusId: { value: 'ORDER_APPROVED' }, orderTypeId: { value: 'SALES_ORDER' }, - facilityId: { value: escapeSolrSpecialChars(this.state.user.currentFacility.facilityId) }, + facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) }, productStoreId: { value: this.state.user.currentEComStore.productStoreId } } } @@ -841,7 +842,7 @@ const actions: ActionTree = { shipGroupSeqId: { value: payload.shipGroupSeqId }, '-fulfillmentStatus': { value: ['Cancelled', 'Rejected']}, '-shipmentMethodTypeId': { value: 'STOREPICKUP' }, - facilityId: { value: escapeSolrSpecialChars(this.state.user.currentFacility.facilityId) }, + facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) }, productStoreId: { value: this.state.user.currentEComStore.productStoreId } } } @@ -908,7 +909,7 @@ const actions: ActionTree = { picklistItemStatusId: { value: '(PICKITEM_PICKED OR (PICKITEM_COMPLETED AND itemShippedDate: [NOW/DAY TO NOW/DAY+1DAY]))' }, '-shipmentMethodTypeId': { value: 'STOREPICKUP' }, shipGroupSeqId: { value: payload.shipGroupSeqId }, - facilityId: { value: escapeSolrSpecialChars(this.state.user.currentFacility.facilityId) }, + facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) }, productStoreId: { value: this.state.user.currentEComStore.productStoreId } } } @@ -1026,7 +1027,7 @@ const actions: ActionTree = { try { // fetchShipments accepts Array parameters for picklistBinId and orderId - const shipmentBatches = await OrderService.fetchShipments([current.picklistBinId], [current.orderId], this.state.user.currentFacility.facilityId) + const shipmentBatches = await OrderService.fetchShipments([current.picklistBinId], [current.orderId], getCurrentFacilityId()) const shipments = shipmentBatches.flat(); const shipmentIds = [...new Set(shipments.map((shipment: any) => shipment.shipmentId))] as Array let shipmentPackages = [] as any; diff --git a/src/store/modules/rejection/actions.ts b/src/store/modules/rejection/actions.ts index dfd6d697..b5fb2de3 100644 --- a/src/store/modules/rejection/actions.ts +++ b/src/store/modules/rejection/actions.ts @@ -7,6 +7,7 @@ import * as types from './mutation-types' import { escapeSolrSpecialChars, prepareSolrQuery } from '@/utils/solrHelper' import { UtilService } from '@/services/UtilService' import logger from '@/logger' +import { getCurrentFacilityId } from '@/utils' const actions: ActionTree = { async fetchRejectionStats({ commit, state }) { @@ -25,7 +26,7 @@ const actions: ActionTree = { viewSize: '0', // passed viewSize as 0 to not fetch any data filters: { rejectedAt_dt: {value: rejectionPeriodFilter}, - rejectedFrom_txt_en: { value: escapeSolrSpecialChars(this.state.user.currentFacility.facilityId) }, + rejectedFrom_txt_en: { value: escapeSolrSpecialChars(getCurrentFacilityId()) }, }, facet: { "total":"unique(orderId_s)", @@ -101,7 +102,7 @@ const actions: ActionTree = { const filters = { - rejectedFrom_txt_en: { value: escapeSolrSpecialChars(this.state.user.currentFacility.facilityId) }, + rejectedFrom_txt_en: { value: escapeSolrSpecialChars(getCurrentFacilityId()) }, } as any //when user search the rejected results are not bound to time duration diff --git a/src/store/modules/stock/actions.ts b/src/store/modules/stock/actions.ts index 0233e673..5330f324 100644 --- a/src/store/modules/stock/actions.ts +++ b/src/store/modules/stock/actions.ts @@ -5,12 +5,12 @@ import StockState from './StockState' import * as types from './mutation-types' import { hasError } from '@/adapter' import logger from '@/logger' -import { showToast } from '@/utils' +import { showToast, getCurrentFacilityId } from '@/utils' import { translate } from '@hotwax/dxp-components' const actions: ActionTree = { async fetchStock({ commit }, { productId, facilityId = '' }) { - const id = facilityId ? facilityId : this.state.user.currentFacility.facilityId + const id = facilityId ? facilityId : getCurrentFacilityId() try { const payload = { diff --git a/src/store/modules/stock/getters.ts b/src/store/modules/stock/getters.ts index 491b222d..40bf6469 100644 --- a/src/store/modules/stock/getters.ts +++ b/src/store/modules/stock/getters.ts @@ -1,11 +1,11 @@ import { GetterTree } from 'vuex' import StockState from './StockState' import RootState from '../../RootState' +import { getCurrentFacilityId } from '@/utils'; const getters: GetterTree = { - getProductStock: (state, getters, RootState) => (productId: any, facilityId?: any) => { - const id = facilityId ? facilityId : RootState.user.currentFacility.facilityId - + getProductStock: (state, getters) => (productId: any, facilityId?: any) => { + const id = facilityId ? facilityId : getCurrentFacilityId() return state.products[productId] ? state.products[productId][id] ? state.products[productId][id] : {} : {} } } diff --git a/src/store/modules/transferorder/actions.ts b/src/store/modules/transferorder/actions.ts index 46c2b969..c926cb8f 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 } from "@/utils"; +import { showToast, getCurrentFacilityId } from "@/utils"; import { UtilService } from '@/services/UtilService' import store from "@/store"; @@ -29,7 +29,7 @@ const actions: ActionTree = { sort: payload.sort ? payload.sort : "orderDate asc", filters: { orderTypeId: { value: 'TRANSFER_ORDER' }, - facilityId: { value: escapeSolrSpecialChars(this.state.user.currentFacility.facilityId) }, + facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) }, productStoreId: { value: this.state.user.currentEComStore.productStoreId } } } @@ -154,7 +154,7 @@ const actions: ActionTree = { "shipmentTypeId": "OUT_TRANSFER", orderId: payload.orderId, "shipGroupSeqId": payload.shipGroupSeqId, - "originFacilityId": this.state.user.currentFacility.facilityId, + "originFacilityId": getCurrentFacilityId(), "destinationFacilityId": payload.orderFacilityId, "items": eligibleItems, "packages": [{ diff --git a/src/store/modules/user/UserState.ts b/src/store/modules/user/UserState.ts index eed51f6a..7cdd85b2 100644 --- a/src/store/modules/user/UserState.ts +++ b/src/store/modules/user/UserState.ts @@ -3,7 +3,6 @@ export default interface UserState { current: any; permissions: any; pwaState: any; - currentFacility: object; instanceUrl: string; currentEComStore: object; preference: { diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index e2f26993..bfa48e46 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 } from '@/utils' +import { showToast, getCurrentFacilityId } from '@/utils' import { hasError } from '@/adapter' import { translate } from '@hotwax/dxp-components' import { DateTime, Settings } from 'luxon'; @@ -56,9 +56,8 @@ 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, "OMS_FULFILLMENT", isAdminUser); - + const facilities = await useUserStore().getUserFacilities(userProfile?.partyId, "OMS_FULFILLMENT", isAdminUser) + await useUserStore().getFacilityPreference('SELECTED_FACILITY') if (!facilities.length) throw 'Unable to login. User is not assocaited with any facility' @@ -71,7 +70,7 @@ const actions: ActionTree = { }, []); // TODO Use a separate API for getting facilities, this should handle user like admin accessing the app - const currentFacility = userProfile.facilities[0]; + const currentFacility: any = useUserStore().getCurrentFacility userProfile.stores = await UserService.getEComStores(token, currentFacility); let preferredStore = userProfile.stores[0] @@ -93,7 +92,6 @@ const actions: ActionTree = { // TODO user single mutation commit(types.USER_CURRENT_ECOM_STORE_UPDATED, preferredStore); - commit(types.USER_CURRENT_FACILITY_UPDATED, currentFacility); commit(types.USER_INFO_UPDATED, userProfile); commit(types.USER_PERMISSIONS_UPDATED, appPermissions); commit(types.USER_TOKEN_CHANGED, { newToken: token }) @@ -660,7 +658,7 @@ 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 as any) @@ -674,7 +672,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 08baaaa1..8dde5e31 100644 --- a/src/store/modules/user/getters.ts +++ b/src/store/modules/user/getters.ts @@ -18,9 +18,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 0431d3ce..6a1fe3d1 100644 --- a/src/store/modules/user/index.ts +++ b/src/store/modules/user/index.ts @@ -11,7 +11,6 @@ const userModule: Module = { token: '', permissions: [], current: {}, - currentFacility: {}, instanceUrl: '', currentEComStore: {}, preference: { diff --git a/src/store/modules/user/mutations.ts b/src/store/modules/user/mutations.ts index 43e20b98..a999e2e0 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.currentEComStore = {} state.permissions = [], state.allNotificationPrefs = [] @@ -17,9 +16,6 @@ const mutations: MutationTree = { [types.USER_INFO_UPDATED] (state, payload) { state.current = { ...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 2a647b5f..9fd3aa1b 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,4 +1,4 @@ -import { translate } from '@hotwax/dxp-components'; +import { translate, useUserStore } from '@hotwax/dxp-components'; import store from '@/store'; import { JsonToCsvOption } from '@/types'; import { Plugins } from '@capacitor/core'; @@ -217,6 +217,11 @@ const dateOrdinalSuffix = { 23: 'rd' } as any +const getCurrentFacilityId = () => { + const currentFacility: any = useUserStore().getCurrentFacility; + return currentFacility?.facilityId +} + function getDateWithOrdinalSuffix(time: any) { if (!time) return "-"; const dateTime = DateTime.fromMillis(time); @@ -224,5 +229,4 @@ function getDateWithOrdinalSuffix(time: any) { return `${dateTime.day}${suffix} ${dateTime.toFormat("MMM yyyy")}`; } - -export { copyToClipboard, formatCurrency, formatDate, formatPhoneNumber, formatUtcDate, generateInternalId, getColorByDesc, getDateWithOrdinalSuffix, getFeature, getIdentificationId, handleDateTimeInput, isValidDeliveryDays, isValidCarrierCode, isPdf, showToast, sortItems, hasError, parseCsv, jsonToCsv } +export { copyToClipboard, formatCurrency, formatDate, formatPhoneNumber, formatUtcDate, generateInternalId, getCurrentFacilityId, getColorByDesc, getDateWithOrdinalSuffix, getFeature, getIdentificationId, handleDateTimeInput, isValidDeliveryDays, isValidCarrierCode, isPdf, showToast, sortItems, hasError, parseCsv, jsonToCsv } diff --git a/src/views/AssignPickerModal.vue b/src/views/AssignPickerModal.vue index 26b74018..3d60444f 100644 --- a/src/views/AssignPickerModal.vue +++ b/src/views/AssignPickerModal.vue @@ -69,12 +69,12 @@ import { IonTitle, IonToolbar, modalController } from "@ionic/vue"; -import { defineComponent } from "vue"; +import { defineComponent, computed } from "vue"; import { closeOutline, saveOutline } from "ionicons/icons"; import { mapGetters, useStore } from "vuex"; import { showToast } from "@/utils"; import { hasError } from "@/adapter"; -import { translate } from '@hotwax/dxp-components' +import { translate, useUserStore } from '@hotwax/dxp-components' import { UtilService } from "@/services/UtilService"; import emitter from "@/event-bus"; import logger from "@/logger" @@ -104,7 +104,6 @@ export default defineComponent({ }, computed: { ...mapGetters({ - currentFacility: 'user/getCurrentFacility', openOrders: 'order/getOpenOrders' }) }, @@ -149,9 +148,9 @@ export default defineComponent({ } const formData = new FormData(); - formData.append("facilityId", this.currentFacility.facilityId); + formData.append("facilityId", this.currentFacility?.facilityId); orderItems.map((item, index) => { - formData.append("facilityId_o_"+index, this.currentFacility.facilityId) + formData.append("facilityId_o_"+index, this.currentFacility?.facilityId) formData.append("shipmentMethodTypeId_o_"+index, item.shipmentMethodTypeId) formData.append("itemStatusId_o_"+index, "PICKITEM_PENDING") formData.append("shipGroupSeqId_o_"+index, item.shipGroupSeqId) @@ -238,9 +237,12 @@ export default defineComponent({ }, setup() { const store = useStore(); + const userStore = useUserStore() + let currentFacility = computed(() => userStore.getCurrentFacility) return { closeOutline, + currentFacility, saveOutline, store, translate diff --git a/src/views/Completed.vue b/src/views/Completed.vue index a274e889..3a3a15e6 100644 --- a/src/views/Completed.vue +++ b/src/views/Completed.vue @@ -212,7 +212,7 @@ import { UtilService } from '@/services/UtilService'; import { prepareOrderQuery } from '@/utils/solrHelper'; import emitter from '@/event-bus'; import ViewSizeSelector from '@/components/ViewSizeSelector.vue' -import { translate } from '@hotwax/dxp-components' +import { translate, useUserStore } from '@hotwax/dxp-components' import { OrderService } from '@/services/OrderService'; import logger from '@/logger'; import ShippingLabelErrorModal from '@/components/ShippingLabelErrorModal.vue'; @@ -263,7 +263,6 @@ export default defineComponent({ ...mapGetters({ completedOrders: 'order/getCompletedOrders', getProduct: 'product/getProduct', - currentFacility: 'user/getCurrentFacility', currentEComStore: 'user/getCurrentEComStore', getPartyName: 'util/getPartyName', getShipmentMethodDesc: 'util/getShipmentMethodDesc', @@ -286,7 +285,7 @@ export default defineComponent({ }, methods: { getErrorMessage() { - return this.searchedQuery === '' ? translate("doesn't have any completed orders right now.", { facilityName: this.currentFacility.facilityName }) : translate( "No results found for . Try searching In Progress or Open tab instead. If you still can't find what you're looking for, try switching stores.", { searchedQuery: this.searchedQuery, lineBreak: '
' }) + return this.searchedQuery === '' ? translate("doesn't have any completed orders right now.", { facilityName: this.currentFacility?.facilityName }) : translate( "No results found for . Try searching In Progress or Open tab instead. If you still can't find what you're looking for, try switching stores.", { searchedQuery: this.searchedQuery, lineBreak: '
' }) }, hasAnyPackedShipment(): boolean { return this.completedOrders.list.some((order: any) => { @@ -482,7 +481,7 @@ export default defineComponent({ filters: { picklistItemStatusId: { value: '(PICKITEM_PICKED OR (PICKITEM_COMPLETED AND itemShippedDate: [NOW/DAY TO NOW/DAY+1DAY]))' }, '-shipmentMethodTypeId': { value: 'STOREPICKUP' }, - facilityId: { value: this.currentFacility.facilityId }, + facilityId: { value: this.currentFacility?.facilityId }, productStoreId: { value: this.currentEComStore.productStoreId } }, facet: { @@ -523,7 +522,7 @@ export default defineComponent({ filters: { picklistItemStatusId: { value: '(PICKITEM_PICKED OR (PICKITEM_COMPLETED AND itemShippedDate: [NOW/DAY TO NOW/DAY+1DAY]))' }, '-shipmentMethodTypeId': { value: 'STOREPICKUP' }, - facilityId: { value: this.currentFacility.facilityId }, + facilityId: { value: this.currentFacility?.facilityId }, productStoreId: { value: this.currentEComStore.productStoreId }, }, facet: { @@ -762,8 +761,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, @@ -772,6 +773,7 @@ export default defineComponent({ copyToClipboard, checkmarkDoneOutline, cubeOutline, + currentFacility, downloadOutline, ellipsisVerticalOutline, formatUtcDate, diff --git a/src/views/DownloadPackedOrders.vue b/src/views/DownloadPackedOrders.vue index 8ca43c98..330c3d5e 100644 --- a/src/views/DownloadPackedOrders.vue +++ b/src/views/DownloadPackedOrders.vue @@ -75,12 +75,12 @@