Skip to content

Commit

Permalink
Improved: used getCurrentFacilityId util function to get current faci…
Browse files Browse the repository at this point in the history
…lity instead of useUserStore from dxp-component in various files(#dxp/288)
  • Loading branch information
R-Sourabh committed Nov 18, 2024
1 parent 3af6dd4 commit 40c4515
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 25 deletions.
8 changes: 5 additions & 3 deletions src/components/DownloadRejectedOrdersModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -136,8 +136,7 @@
computed: {
...mapGetters({
getProduct: 'product/getProduct',
rejectedOrders: 'rejection/getRejectedOrders',
currentFacility: 'user/getCurrentFacility',
rejectedOrders: 'rejection/getRejectedOrders'
})
},
methods: {
Expand Down Expand Up @@ -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 {
Expand All @@ -308,6 +309,7 @@
productIdentificationPref,
store,
translate,
currentFacility
}
}
});
Expand Down
24 changes: 8 additions & 16 deletions src/store/modules/order/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ const actions: ActionTree<OrderState, RootState> = {
// 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;
Expand All @@ -173,7 +172,7 @@ const actions: ActionTree<OrderState, RootState> = {
}

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();

Expand Down Expand Up @@ -312,7 +311,6 @@ const actions: ActionTree<OrderState, RootState> = {
let resp;
let orders = [];
let total = 0;
const currentFacilityId = getCurrentFacilityId();

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

Expand All @@ -327,7 +325,7 @@ const actions: ActionTree<OrderState, RootState> = {
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 }
}
}
Expand Down Expand Up @@ -406,7 +404,6 @@ const actions: ActionTree<OrderState, RootState> = {
async findOpenOrders ({ commit, state }, payload = {}) {
emitter.emit('presentLoader');
let resp;
const currentFacilityId = getCurrentFacilityId();

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

Expand All @@ -422,7 +419,7 @@ const actions: ActionTree<OrderState, RootState> = {
'-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 }
}
}
Expand Down Expand Up @@ -481,7 +478,6 @@ const actions: ActionTree<OrderState, RootState> = {
async findCompletedOrders ({ commit, dispatch, state }, payload = {}) {
emitter.emit('presentLoader');
let resp;
const currentFacilityId = getCurrentFacilityId();

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

Expand All @@ -494,7 +490,7 @@ const actions: ActionTree<OrderState, RootState> = {
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 }
}
}
Expand Down Expand Up @@ -764,7 +760,6 @@ const actions: ActionTree<OrderState, RootState> = {
}

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

const params = {
Expand All @@ -778,7 +773,7 @@ const actions: ActionTree<OrderState, RootState> = {
'-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 }
}
}
Expand Down Expand Up @@ -835,7 +830,6 @@ const actions: ActionTree<OrderState, RootState> = {
}
emitter.emit('presentLoader');
let resp, order = {} as any;
const currentFacilityId = getCurrentFacilityId();

try {
const params = {
Expand All @@ -848,7 +842,7 @@ const actions: ActionTree<OrderState, RootState> = {
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 }
}
}
Expand Down Expand Up @@ -904,7 +898,6 @@ const actions: ActionTree<OrderState, RootState> = {
}
emitter.emit('presentLoader');
let resp, order = {} as any;
const currentFacilityId = getCurrentFacilityId();

try {
const params = {
Expand All @@ -916,7 +909,7 @@ const actions: ActionTree<OrderState, RootState> = {
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 }
}
}
Expand Down Expand Up @@ -1031,11 +1024,10 @@ const actions: ActionTree<OrderState, RootState> = {

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<string>
let shipmentPackages = [] as any;
Expand Down
5 changes: 3 additions & 2 deletions src/store/modules/rejection/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<RejectionState, RootState> = {
async fetchRejectionStats({ commit, state }) {
Expand All @@ -25,7 +26,7 @@ const actions: ActionTree<RejectionState, RootState> = {
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)",
Expand Down Expand Up @@ -101,7 +102,7 @@ const actions: ActionTree<RejectionState, RootState> = {


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
Expand Down
1 change: 0 additions & 1 deletion src/views/OrderLookup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 4 additions & 2 deletions src/views/Rejections.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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 {
Expand All @@ -344,6 +345,7 @@ export default defineComponent({
productIdentificationPref,
store,
translate,
currentFacility
}
}
});
Expand Down
1 change: 0 additions & 1 deletion src/views/TransferOrderDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@
...mapGetters({
currentOrder: 'transferorder/getCurrent',
getStatusDesc: 'util/getStatusDesc',
user: 'user/getCurrentFacility',
getProduct: 'product/getProduct',
productIdentificationPref: 'user/getProductIdentificationPref',
productStoreShipmentMethCount: 'util/getProductStoreShipmentMethCount',
Expand Down

0 comments on commit 40c4515

Please sign in to comment.