diff --git a/src/services/ProductService.ts b/src/services/ProductService.ts index 160f6616..bb73840a 100644 --- a/src/services/ProductService.ts +++ b/src/services/ProductService.ts @@ -1,5 +1,5 @@ import { api, hasError } from '@/adapter'; -import store from '@/store'; +import { getCurrentFacilityId } from '@/utils'; const fetchProducts = async (query: any): Promise => { return api({ @@ -14,7 +14,7 @@ const getInventoryAvailableByFacility = async (productId: any): Promise => let productQoh = '' const payload = { productId: productId, - facilityId: store.getters['user/getCurrentFacility']?.facilityId + facilityId: getCurrentFacilityId() } try { diff --git a/src/store/modules/order/actions.ts b/src/store/modules/order/actions.ts index a5da893a..2a775561 100644 --- a/src/store/modules/order/actions.ts +++ b/src/store/modules/order/actions.ts @@ -4,7 +4,7 @@ import RootState from '@/store/RootState' import OrderState from './OrderState' import * as types from './mutation-types' import { hasError, showToast, getCurrentFacilityId } from '@/utils' -import { getProductIdentificationValue, translate, useUserStore } from '@hotwax/dxp-components' +import { getProductIdentificationValue, translate } from '@hotwax/dxp-components' import emitter from "@/event-bus"; import store from "@/store"; @@ -70,7 +70,6 @@ const actions: ActionTree = { }, async getOrderDetail({ commit, state }, { orderId }) { let resp; - const currentFacilityId = getCurrentFacilityId(); try { const payload = { @@ -83,7 +82,7 @@ const actions: ActionTree = { }, "query": "docType:ORDER", "filter": [ - `orderTypeId: PURCHASE_ORDER AND orderId: ${orderId} AND orderStatusId: (ORDER_APPROVED OR ORDER_CREATED OR ORDER_COMPLETED) AND facilityId: ${currentFacilityId}` + `orderTypeId: PURCHASE_ORDER AND orderId: ${orderId} AND orderStatusId: (ORDER_APPROVED OR ORDER_CREATED OR ORDER_COMPLETED) AND facilityId: ${getCurrentFacilityId()}` ] } } @@ -161,7 +160,7 @@ const actions: ActionTree = { const params = { orderId: payload.orderId, - destinationFacilityId: this.state.user.currentFacility.facilityId, + destinationFacilityId: getCurrentFacilityId(), "type": "PURCHASE_SHIPMENT", "status": "PURCH_SHIP_CREATED", "items": payload.items @@ -169,7 +168,7 @@ const actions: ActionTree = { resp = await OrderService.createIncomingShipment({"payload": params}) if (resp.status === 200 && !hasError(resp) && resp.data.shipmentId) { - const facilityLocations = await this.dispatch('user/getFacilityLocations', this.state.user.currentFacility.facilityId); + const facilityLocations = await this.dispatch('user/getFacilityLocations', getCurrentFacilityId()); if (facilityLocations.length){ const locationSeqId = facilityLocations[0].locationSeqId payload.items.map((item: any) => { @@ -209,8 +208,7 @@ const actions: ActionTree = { "orderBy": 'datetimeReceived DESC', "viewSize": "250" } - const currentFacilityId = getCurrentFacilityId() - const facilityLocations = await this.dispatch('user/getFacilityLocations', currentFacilityId); + const facilityLocations = await this.dispatch('user/getFacilityLocations', getCurrentFacilityId()); const locationSeqId = facilityLocations.length > 0 ? facilityLocations[0].locationSeqId : ""; resp = await OrderService.fetchPOHistory(params) if (resp.status === 200 && !hasError(resp) && resp.data?.count > 0) { diff --git a/src/store/modules/shipment/actions.ts b/src/store/modules/shipment/actions.ts index f920aa16..181a286f 100644 --- a/src/store/modules/shipment/actions.ts +++ b/src/store/modules/shipment/actions.ts @@ -72,8 +72,7 @@ const actions: ActionTree = { const shipmentAttributes = await ShipmentService.fetchShipmentAttributes([shipmentDetail.shipmentId]) shipmentDetail.externalOrderId = shipmentAttributes?.[shipmentDetail.shipmentId]?.['EXTERNAL_ORDER_ID'] shipmentDetail.externalOrderName = shipmentAttributes?.[shipmentDetail.shipmentId]?.['EXTERNAL_ORDER_NAME'] - const currentFacilityId = getCurrentFacilityId(); - const facilityLocations = await this.dispatch('user/getFacilityLocations', currentFacilityId); + const facilityLocations = await this.dispatch('user/getFacilityLocations', getCurrentFacilityId()); if(facilityLocations.length){ const locationSeqId = facilityLocations[0].locationSeqId resp.data.items.map((item: any) => { @@ -106,7 +105,6 @@ const actions: ActionTree = { } }, async receiveShipmentItem ({ commit }, payload) { - const currentFacilityId = getCurrentFacilityId(); let areAllSuccess = true; for (const item of payload.items) { @@ -119,7 +117,7 @@ const actions: ActionTree = { const params = { shipmentId: payload.shipmentId, - facilityId: currentFacilityId, + facilityId: getCurrentFacilityId(), shipmentItemSeqId: item.itemSeqId, productId: item.productId, quantityAccepted: item.quantityAccepted, @@ -154,7 +152,7 @@ const actions: ActionTree = { const uploadData = payload.items.map((item: any) => { return { shipmentId: payload.shipmentId, - facilityId: this.state.user.currentFacility.facilityId, + facilityId: getCurrentFacilityId(), shipmentItemSeqId: item.itemSeqId, productId: item.productId, quantityAccepted: item.quantityAccepted, diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index e3169ac8..63dae224 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -3,7 +3,7 @@ import { ActionTree } from 'vuex' import RootState from '@/store/RootState' import UserState from './UserState' import * as types from './mutation-types' -import { hasError, showToast } from '@/utils' +import { getCurrentFacilityId, hasError, showToast } from '@/utils' import { Settings } from 'luxon'; import { logout, updateInstanceUrl, updateToken, resetConfig } from '@/adapter' import { @@ -71,7 +71,7 @@ const actions: ActionTree = { return uniqueFacilities }, []); - const currentFacility: any = useUserStore().getCurrentFacility + const currentFacility: any = getCurrentFacilityId(); const currentEComStore = await UserService.getEComStores(token, currentFacility?.facilityId); const productStoreId = currentEComStore?.productStoreId; diff --git a/src/views/ReturnDetails.vue b/src/views/ReturnDetails.vue index 7b64e230..8c319927 100644 --- a/src/views/ReturnDetails.vue +++ b/src/views/ReturnDetails.vue @@ -167,7 +167,6 @@ export default defineComponent({ computed: { ...mapGetters({ current: 'return/getCurrent', - user: 'user/getCurrentFacility', getProduct: 'product/getProduct', facilityLocationsByFacilityId: 'user/getFacilityLocationsByFacilityId', returns: 'return/getReturns', diff --git a/src/views/ShipmentDetails.vue b/src/views/ShipmentDetails.vue index 97d2c374..1a25b800 100644 --- a/src/views/ShipmentDetails.vue +++ b/src/views/ShipmentDetails.vue @@ -120,7 +120,7 @@ import { defineComponent, computed } from 'vue'; import { add, checkmarkDone, checkmarkDoneCircleOutline, cameraOutline, cubeOutline, locationOutline, warningOutline } from 'ionicons/icons'; import { mapGetters, useStore } from "vuex"; import AddProductModal from '@/views/AddProductModal.vue' -import { DxpShopifyImg, translate, getProductIdentificationValue, useProductIdentificationStore, useUserStore } from '@hotwax/dxp-components'; +import { DxpShopifyImg, translate, getProductIdentificationValue, useProductIdentificationStore } from '@hotwax/dxp-components'; import { useRouter } from 'vue-router'; import Scanner from "@/components/Scanner.vue"; import ImageModal from '@/components/ImageModal.vue'; @@ -167,7 +167,6 @@ export default defineComponent({ computed: { ...mapGetters({ current: 'shipment/getCurrent', - user: 'user/getCurrentFacility', getProduct: 'product/getProduct', facilityLocationsByFacilityId: 'user/getFacilityLocationsByFacilityId', isForceScanEnabled: 'util/isForceScanEnabled', @@ -354,10 +353,8 @@ 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, @@ -366,7 +363,6 @@ export default defineComponent({ checkmarkDone, checkmarkDoneCircleOutline, cubeOutline, - currentFacility, hasPermission, locationOutline, store,