From 40c4515e773dd16fb10ad0f24a53ca9bdab3a677 Mon Sep 17 00:00:00 2001 From: R-Sourabh Date: Mon, 18 Nov 2024 20:16:05 +0530 Subject: [PATCH] Improved: used getCurrentFacilityId util function to get current facility instead of useUserStore from dxp-component in various files(#dxp/288) --- .../DownloadRejectedOrdersModal.vue | 8 ++++--- src/store/modules/order/actions.ts | 24 +++++++------------ src/store/modules/rejection/actions.ts | 5 ++-- src/views/OrderLookup.vue | 1 - src/views/Rejections.vue | 6 +++-- src/views/TransferOrderDetail.vue | 1 - 6 files changed, 20 insertions(+), 25 deletions(-) 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/store/modules/order/actions.ts b/src/store/modules/order/actions.ts index 69e6f8da..5517cf84 100644 --- a/src/store/modules/order/actions.ts +++ b/src/store/modules/order/actions.ts @@ -152,7 +152,6 @@ const actions: ActionTree = { // getting all the orders from state const cachedOrders = JSON.parse(JSON.stringify(state.completed.list)); // maintaining cachedOrders as to prepare the orders payload let completedOrders = JSON.parse(JSON.stringify(state.completed.list)); // maintaining completedOrders as update the orders information once information in fetched - const currentFacilityId = getCurrentFacilityId(); // Split orders in batch of 40 const batchSize = 20; @@ -173,7 +172,7 @@ const actions: ActionTree = { } try { - const shipmentbatches = await Promise.all(requestParams.map((params) => OrderService.fetchShipments(params.picklistBinIds, params.orderIds, currentFacilityId))) + 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(); @@ -312,7 +311,6 @@ const actions: ActionTree = { let resp; let orders = []; let total = 0; - const currentFacilityId = getCurrentFacilityId(); const inProgressQuery = JSON.parse(JSON.stringify(state.inProgress.query)) @@ -327,7 +325,7 @@ const actions: ActionTree = { picklistItemStatusId: { value: 'PICKITEM_PENDING' }, '-fulfillmentStatus': { value: ['Rejected', 'Cancelled'] }, '-shipmentMethodTypeId': { value: 'STOREPICKUP' }, - facilityId: { value: escapeSolrSpecialChars(currentFacilityId) }, + facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) }, productStoreId: { value: this.state.user.currentEComStore.productStoreId } } } @@ -406,7 +404,6 @@ const actions: ActionTree = { async findOpenOrders ({ commit, state }, payload = {}) { emitter.emit('presentLoader'); let resp; - const currentFacilityId = getCurrentFacilityId(); const openOrderQuery = JSON.parse(JSON.stringify(state.open.query)) @@ -422,7 +419,7 @@ const actions: ActionTree = { '-fulfillmentStatus': { value: ['Cancelled', 'Rejected']}, orderStatusId: { value: 'ORDER_APPROVED' }, orderTypeId: { value: 'SALES_ORDER' }, - facilityId: { value: escapeSolrSpecialChars(currentFacilityId) }, + facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) }, productStoreId: { value: this.state.user.currentEComStore.productStoreId } } } @@ -481,7 +478,6 @@ const actions: ActionTree = { async findCompletedOrders ({ commit, dispatch, state }, payload = {}) { emitter.emit('presentLoader'); let resp; - const currentFacilityId = getCurrentFacilityId(); const completedOrderQuery = JSON.parse(JSON.stringify(state.completed.query)) @@ -494,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(currentFacilityId) }, + facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) }, productStoreId: { value: this.state.user.currentEComStore.productStoreId } } } @@ -764,7 +760,6 @@ const actions: ActionTree = { } let resp, order = {} as any; - const currentFacilityId = getCurrentFacilityId(); emitter.emit('presentLoader'); const params = { @@ -778,7 +773,7 @@ const actions: ActionTree = { '-fulfillmentStatus': { value: ['Cancelled', 'Rejected']}, orderStatusId: { value: 'ORDER_APPROVED' }, orderTypeId: { value: 'SALES_ORDER' }, - facilityId: { value: escapeSolrSpecialChars(currentFacilityId) }, + facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) }, productStoreId: { value: this.state.user.currentEComStore.productStoreId } } } @@ -835,7 +830,6 @@ const actions: ActionTree = { } emitter.emit('presentLoader'); let resp, order = {} as any; - const currentFacilityId = getCurrentFacilityId(); try { const params = { @@ -848,7 +842,7 @@ const actions: ActionTree = { shipGroupSeqId: { value: payload.shipGroupSeqId }, '-fulfillmentStatus': { value: ['Cancelled', 'Rejected']}, '-shipmentMethodTypeId': { value: 'STOREPICKUP' }, - facilityId: { value: escapeSolrSpecialChars(currentFacilityId) }, + facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) }, productStoreId: { value: this.state.user.currentEComStore.productStoreId } } } @@ -904,7 +898,6 @@ const actions: ActionTree = { } emitter.emit('presentLoader'); let resp, order = {} as any; - const currentFacilityId = getCurrentFacilityId(); try { const params = { @@ -916,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(currentFacilityId) }, + facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) }, productStoreId: { value: this.state.user.currentEComStore.productStoreId } } } @@ -1031,11 +1024,10 @@ const actions: ActionTree = { async fetchCompletedOrderAdditionalInformation({ dispatch }, order) { let current = JSON.parse(JSON.stringify(order)) - const currentFacilityId = getCurrentFacilityId(); try { // fetchShipments accepts Array parameters for picklistBinId and orderId - const shipmentBatches = await OrderService.fetchShipments([current.picklistBinId], [current.orderId], currentFacilityId) + 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/views/OrderLookup.vue b/src/views/OrderLookup.vue index 2c41e9f3..df96defa 100644 --- a/src/views/OrderLookup.vue +++ b/src/views/OrderLookup.vue @@ -193,7 +193,6 @@ export default defineComponent ({ ...mapGetters({ ordersList: 'orderLookup/getOrders', getProduct: 'product/getProduct', - currentFacilityId: 'user/getCurrentFacility', getProductStock: 'stock/getProductStock', isScrollable: 'orderLookup/isScrollable', query: 'orderLookup/getOrderQuery', diff --git a/src/views/Rejections.vue b/src/views/Rejections.vue index 502c47ec..af9d9914 100644 --- a/src/views/Rejections.vue +++ b/src/views/Rejections.vue @@ -241,8 +241,7 @@ export default defineComponent({ ...mapGetters({ rejectionStats: 'rejection/getRejectedStats', getProduct: 'product/getProduct', - rejectedOrders: 'rejection/getRejectedOrders', - currentFacility: 'user/getCurrentFacility', + rejectedOrders: 'rejection/getRejectedOrders' }) }, async ionViewWillEnter() { @@ -327,8 +326,10 @@ 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 { @@ -344,6 +345,7 @@ export default defineComponent({ productIdentificationPref, store, translate, + currentFacility } } }); diff --git a/src/views/TransferOrderDetail.vue b/src/views/TransferOrderDetail.vue index 1408175b..64224887 100644 --- a/src/views/TransferOrderDetail.vue +++ b/src/views/TransferOrderDetail.vue @@ -217,7 +217,6 @@ ...mapGetters({ currentOrder: 'transferorder/getCurrent', getStatusDesc: 'util/getStatusDesc', - user: 'user/getCurrentFacility', getProduct: 'product/getProduct', productIdentificationPref: 'user/getProductIdentificationPref', productStoreShipmentMethCount: 'util/getProductStoreShipmentMethCount',