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 e5f615b commit 7a2be33
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/services/ProductService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { api, hasError } from '@/adapter';
import store from '@/store';
import { getCurrentFacilityId } from '@/utils';

const fetchProducts = async (query: any): Promise <any> => {
return api({
Expand All @@ -14,7 +14,7 @@ const getInventoryAvailableByFacility = async (productId: any): Promise<any> =>
let productQoh = ''
const payload = {
productId: productId,
facilityId: store.getters['user/getCurrentFacility']?.facilityId
facilityId: getCurrentFacilityId()
}

try {
Expand Down
12 changes: 5 additions & 7 deletions src/store/modules/order/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -70,7 +70,6 @@ const actions: ActionTree<OrderState, RootState> = {
},
async getOrderDetail({ commit, state }, { orderId }) {

Check warning on line 71 in src/store/modules/order/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'state' is defined but never used

Check warning on line 71 in src/store/modules/order/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'state' is defined but never used
let resp;
const currentFacilityId = getCurrentFacilityId();

try {
const payload = {
Expand All @@ -83,7 +82,7 @@ const actions: ActionTree<OrderState, RootState> = {
},
"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()}`
]
}
}
Expand Down Expand Up @@ -161,15 +160,15 @@ const actions: ActionTree<OrderState, RootState> = {

const params = {
orderId: payload.orderId,
destinationFacilityId: this.state.user.currentFacility.facilityId,
destinationFacilityId: getCurrentFacilityId(),
"type": "PURCHASE_SHIPMENT",
"status": "PURCH_SHIP_CREATED",
"items": payload.items
}
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) => {
Expand Down Expand Up @@ -209,8 +208,7 @@ const actions: ActionTree<OrderState, RootState> = {
"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) {
Expand Down
8 changes: 3 additions & 5 deletions src/store/modules/shipment/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ const actions: ActionTree<ShipmentState, RootState> = {
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) => {
Expand Down Expand Up @@ -106,7 +105,6 @@ const actions: ActionTree<ShipmentState, RootState> = {
}
},
async receiveShipmentItem ({ commit }, payload) {

Check warning on line 107 in src/store/modules/shipment/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'commit' is defined but never used

Check warning on line 107 in src/store/modules/shipment/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'commit' is defined but never used
const currentFacilityId = getCurrentFacilityId();
let areAllSuccess = true;

for (const item of payload.items) {
Expand All @@ -119,7 +117,7 @@ const actions: ActionTree<ShipmentState, RootState> = {

const params = {
shipmentId: payload.shipmentId,
facilityId: currentFacilityId,
facilityId: getCurrentFacilityId(),
shipmentItemSeqId: item.itemSeqId,
productId: item.productId,
quantityAccepted: item.quantityAccepted,
Expand Down Expand Up @@ -154,7 +152,7 @@ const actions: ActionTree<ShipmentState, RootState> = {
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,
Expand Down
4 changes: 2 additions & 2 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -71,7 +71,7 @@ const actions: ActionTree<UserState, RootState> = {
return uniqueFacilities
}, []);

const currentFacility: any = useUserStore().getCurrentFacility
const currentFacility: any = getCurrentFacilityId();
const currentEComStore = await UserService.getEComStores(token, currentFacility?.facilityId);
const productStoreId = currentEComStore?.productStoreId;

Expand Down
1 change: 0 additions & 1 deletion src/views/ReturnDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ export default defineComponent({
computed: {
...mapGetters({
current: 'return/getCurrent',
user: 'user/getCurrentFacility',
getProduct: 'product/getProduct',
facilityLocationsByFacilityId: 'user/getFacilityLocationsByFacilityId',
returns: 'return/getReturns',
Expand Down
6 changes: 1 addition & 5 deletions src/views/ShipmentDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -167,7 +167,6 @@ export default defineComponent({
computed: {
...mapGetters({
current: 'shipment/getCurrent',
user: 'user/getCurrentFacility',
getProduct: 'product/getProduct',
facilityLocationsByFacilityId: 'user/getFacilityLocationsByFacilityId',
isForceScanEnabled: 'util/isForceScanEnabled',
Expand Down Expand Up @@ -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,
Expand All @@ -366,7 +363,6 @@ export default defineComponent({
checkmarkDone,
checkmarkDoneCircleOutline,
cubeOutline,
currentFacility,
hasPermission,
locationOutline,
store,
Expand Down

0 comments on commit 7a2be33

Please sign in to comment.