Skip to content

Commit 40c4515

Browse files
committed
Improved: used getCurrentFacilityId util function to get current facility instead of useUserStore from dxp-component in various files(#dxp/288)
1 parent 3af6dd4 commit 40c4515

File tree

6 files changed

+20
-25
lines changed

6 files changed

+20
-25
lines changed

src/components/DownloadRejectedOrdersModal.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
} from '@ionic/vue';
7373
import { computed, defineComponent } from 'vue';
7474
import { closeOutline, cloudDownloadOutline} from 'ionicons/icons';
75-
import { getProductIdentificationValue, translate, useProductIdentificationStore } from '@hotwax/dxp-components';
75+
import { getProductIdentificationValue, translate, useProductIdentificationStore, useUserStore } from '@hotwax/dxp-components';
7676
import { mapGetters, useStore } from 'vuex';
7777
import { escapeSolrSpecialChars, prepareSolrQuery } from '@/utils/solrHelper'
7878
import { RejectionService } from '@/services/RejectionService'
@@ -136,8 +136,7 @@
136136
computed: {
137137
...mapGetters({
138138
getProduct: 'product/getProduct',
139-
rejectedOrders: 'rejection/getRejectedOrders',
140-
currentFacility: 'user/getCurrentFacility',
139+
rejectedOrders: 'rejection/getRejectedOrders'
141140
})
142141
},
143142
methods: {
@@ -297,8 +296,10 @@
297296
},
298297
setup() {
299298
const store = useStore()
299+
const userStore = useUserStore()
300300
const productIdentificationStore = useProductIdentificationStore();
301301
let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref)
302+
let currentFacility: any = computed(() => userStore.getCurrentFacility)
302303
303304
304305
return {
@@ -308,6 +309,7 @@
308309
productIdentificationPref,
309310
store,
310311
translate,
312+
currentFacility
311313
}
312314
}
313315
});

src/store/modules/order/actions.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ const actions: ActionTree<OrderState, RootState> = {
152152
// getting all the orders from state
153153
const cachedOrders = JSON.parse(JSON.stringify(state.completed.list)); // maintaining cachedOrders as to prepare the orders payload
154154
let completedOrders = JSON.parse(JSON.stringify(state.completed.list)); // maintaining completedOrders as update the orders information once information in fetched
155-
const currentFacilityId = getCurrentFacilityId();
156155

157156
// Split orders in batch of 40
158157
const batchSize = 20;
@@ -173,7 +172,7 @@ const actions: ActionTree<OrderState, RootState> = {
173172
}
174173

175174
try {
176-
const shipmentbatches = await Promise.all(requestParams.map((params) => OrderService.fetchShipments(params.picklistBinIds, params.orderIds, currentFacilityId)))
175+
const shipmentbatches = await Promise.all(requestParams.map((params) => OrderService.fetchShipments(params.picklistBinIds, params.orderIds, getCurrentFacilityId())))
177176
// TODO simplify below logic by returning shipments list
178177
const shipments = shipmentbatches.flat();
179178

@@ -312,7 +311,6 @@ const actions: ActionTree<OrderState, RootState> = {
312311
let resp;
313312
let orders = [];
314313
let total = 0;
315-
const currentFacilityId = getCurrentFacilityId();
316314

317315
const inProgressQuery = JSON.parse(JSON.stringify(state.inProgress.query))
318316

@@ -327,7 +325,7 @@ const actions: ActionTree<OrderState, RootState> = {
327325
picklistItemStatusId: { value: 'PICKITEM_PENDING' },
328326
'-fulfillmentStatus': { value: ['Rejected', 'Cancelled'] },
329327
'-shipmentMethodTypeId': { value: 'STOREPICKUP' },
330-
facilityId: { value: escapeSolrSpecialChars(currentFacilityId) },
328+
facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) },
331329
productStoreId: { value: this.state.user.currentEComStore.productStoreId }
332330
}
333331
}
@@ -406,7 +404,6 @@ const actions: ActionTree<OrderState, RootState> = {
406404
async findOpenOrders ({ commit, state }, payload = {}) {
407405
emitter.emit('presentLoader');
408406
let resp;
409-
const currentFacilityId = getCurrentFacilityId();
410407

411408
const openOrderQuery = JSON.parse(JSON.stringify(state.open.query))
412409

@@ -422,7 +419,7 @@ const actions: ActionTree<OrderState, RootState> = {
422419
'-fulfillmentStatus': { value: ['Cancelled', 'Rejected']},
423420
orderStatusId: { value: 'ORDER_APPROVED' },
424421
orderTypeId: { value: 'SALES_ORDER' },
425-
facilityId: { value: escapeSolrSpecialChars(currentFacilityId) },
422+
facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) },
426423
productStoreId: { value: this.state.user.currentEComStore.productStoreId }
427424
}
428425
}
@@ -481,7 +478,6 @@ const actions: ActionTree<OrderState, RootState> = {
481478
async findCompletedOrders ({ commit, dispatch, state }, payload = {}) {
482479
emitter.emit('presentLoader');
483480
let resp;
484-
const currentFacilityId = getCurrentFacilityId();
485481

486482
const completedOrderQuery = JSON.parse(JSON.stringify(state.completed.query))
487483

@@ -494,7 +490,7 @@ const actions: ActionTree<OrderState, RootState> = {
494490
filters: {
495491
picklistItemStatusId: { value: '(PICKITEM_PICKED OR (PICKITEM_COMPLETED AND itemShippedDate: [NOW/DAY TO NOW/DAY+1DAY]))' },
496492
'-shipmentMethodTypeId': { value: 'STOREPICKUP' },
497-
facilityId: { value: escapeSolrSpecialChars(currentFacilityId) },
493+
facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) },
498494
productStoreId: { value: this.state.user.currentEComStore.productStoreId }
499495
}
500496
}
@@ -764,7 +760,6 @@ const actions: ActionTree<OrderState, RootState> = {
764760
}
765761

766762
let resp, order = {} as any;
767-
const currentFacilityId = getCurrentFacilityId();
768763
emitter.emit('presentLoader');
769764

770765
const params = {
@@ -778,7 +773,7 @@ const actions: ActionTree<OrderState, RootState> = {
778773
'-fulfillmentStatus': { value: ['Cancelled', 'Rejected']},
779774
orderStatusId: { value: 'ORDER_APPROVED' },
780775
orderTypeId: { value: 'SALES_ORDER' },
781-
facilityId: { value: escapeSolrSpecialChars(currentFacilityId) },
776+
facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) },
782777
productStoreId: { value: this.state.user.currentEComStore.productStoreId }
783778
}
784779
}
@@ -835,7 +830,6 @@ const actions: ActionTree<OrderState, RootState> = {
835830
}
836831
emitter.emit('presentLoader');
837832
let resp, order = {} as any;
838-
const currentFacilityId = getCurrentFacilityId();
839833

840834
try {
841835
const params = {
@@ -848,7 +842,7 @@ const actions: ActionTree<OrderState, RootState> = {
848842
shipGroupSeqId: { value: payload.shipGroupSeqId },
849843
'-fulfillmentStatus': { value: ['Cancelled', 'Rejected']},
850844
'-shipmentMethodTypeId': { value: 'STOREPICKUP' },
851-
facilityId: { value: escapeSolrSpecialChars(currentFacilityId) },
845+
facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) },
852846
productStoreId: { value: this.state.user.currentEComStore.productStoreId }
853847
}
854848
}
@@ -904,7 +898,6 @@ const actions: ActionTree<OrderState, RootState> = {
904898
}
905899
emitter.emit('presentLoader');
906900
let resp, order = {} as any;
907-
const currentFacilityId = getCurrentFacilityId();
908901

909902
try {
910903
const params = {
@@ -916,7 +909,7 @@ const actions: ActionTree<OrderState, RootState> = {
916909
picklistItemStatusId: { value: '(PICKITEM_PICKED OR (PICKITEM_COMPLETED AND itemShippedDate: [NOW/DAY TO NOW/DAY+1DAY]))' },
917910
'-shipmentMethodTypeId': { value: 'STOREPICKUP' },
918911
shipGroupSeqId: { value: payload.shipGroupSeqId },
919-
facilityId: { value: escapeSolrSpecialChars(currentFacilityId) },
912+
facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) },
920913
productStoreId: { value: this.state.user.currentEComStore.productStoreId }
921914
}
922915
}
@@ -1031,11 +1024,10 @@ const actions: ActionTree<OrderState, RootState> = {
10311024

10321025
async fetchCompletedOrderAdditionalInformation({ dispatch }, order) {
10331026
let current = JSON.parse(JSON.stringify(order))
1034-
const currentFacilityId = getCurrentFacilityId();
10351027

10361028
try {
10371029
// fetchShipments accepts Array parameters for picklistBinId and orderId
1038-
const shipmentBatches = await OrderService.fetchShipments([current.picklistBinId], [current.orderId], currentFacilityId)
1030+
const shipmentBatches = await OrderService.fetchShipments([current.picklistBinId], [current.orderId], getCurrentFacilityId())
10391031
const shipments = shipmentBatches.flat();
10401032
const shipmentIds = [...new Set(shipments.map((shipment: any) => shipment.shipmentId))] as Array<string>
10411033
let shipmentPackages = [] as any;

src/store/modules/rejection/actions.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as types from './mutation-types'
77
import { escapeSolrSpecialChars, prepareSolrQuery } from '@/utils/solrHelper'
88
import { UtilService } from '@/services/UtilService'
99
import logger from '@/logger'
10+
import { getCurrentFacilityId } from '@/utils'
1011

1112
const actions: ActionTree<RejectionState, RootState> = {
1213
async fetchRejectionStats({ commit, state }) {
@@ -25,7 +26,7 @@ const actions: ActionTree<RejectionState, RootState> = {
2526
viewSize: '0', // passed viewSize as 0 to not fetch any data
2627
filters: {
2728
rejectedAt_dt: {value: rejectionPeriodFilter},
28-
rejectedFrom_txt_en: { value: escapeSolrSpecialChars(this.state.user.currentFacility.facilityId) },
29+
rejectedFrom_txt_en: { value: escapeSolrSpecialChars(getCurrentFacilityId()) },
2930
},
3031
facet: {
3132
"total":"unique(orderId_s)",
@@ -101,7 +102,7 @@ const actions: ActionTree<RejectionState, RootState> = {
101102

102103

103104
const filters = {
104-
rejectedFrom_txt_en: { value: escapeSolrSpecialChars(this.state.user.currentFacility.facilityId) },
105+
rejectedFrom_txt_en: { value: escapeSolrSpecialChars(getCurrentFacilityId()) },
105106
} as any
106107

107108
//when user search the rejected results are not bound to time duration

src/views/OrderLookup.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ export default defineComponent ({
193193
...mapGetters({
194194
ordersList: 'orderLookup/getOrders',
195195
getProduct: 'product/getProduct',
196-
currentFacilityId: 'user/getCurrentFacility',
197196
getProductStock: 'stock/getProductStock',
198197
isScrollable: 'orderLookup/isScrollable',
199198
query: 'orderLookup/getOrderQuery',

src/views/Rejections.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,7 @@ export default defineComponent({
241241
...mapGetters({
242242
rejectionStats: 'rejection/getRejectedStats',
243243
getProduct: 'product/getProduct',
244-
rejectedOrders: 'rejection/getRejectedOrders',
245-
currentFacility: 'user/getCurrentFacility',
244+
rejectedOrders: 'rejection/getRejectedOrders'
246245
})
247246
},
248247
async ionViewWillEnter() {
@@ -327,8 +326,10 @@ export default defineComponent({
327326
},
328327
setup() {
329328
const store = useStore()
329+
const userStore = useUserStore()
330330
const productIdentificationStore = useProductIdentificationStore();
331331
let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref)
332+
let currentFacility: any = computed(() => userStore.getCurrentFacility)
332333
333334
334335
return {
@@ -344,6 +345,7 @@ export default defineComponent({
344345
productIdentificationPref,
345346
store,
346347
translate,
348+
currentFacility
347349
}
348350
}
349351
});

src/views/TransferOrderDetail.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@
217217
...mapGetters({
218218
currentOrder: 'transferorder/getCurrent',
219219
getStatusDesc: 'util/getStatusDesc',
220-
user: 'user/getCurrentFacility',
221220
getProduct: 'product/getProduct',
222221
productIdentificationPref: 'user/getProductIdentificationPref',
223222
productStoreShipmentMethCount: 'util/getProductStoreShipmentMethCount',

0 commit comments

Comments
 (0)