-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented: Added the support for using facility selector from dxp-component(#dxp/228) #384
Changes from 2 commits
c9ef649
72eb48f
4acc2c4
3d1599f
ae76142
e5f615b
7a2be33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,8 +16,8 @@ | |
"@casl/ability": "^6.0.0", | ||
"@hotwax/app-version-info": "^1.0.0", | ||
"@hotwax/apps-theme": "^1.2.6", | ||
"@hotwax/dxp-components": "^1.13.0", | ||
"@hotwax/oms-api": "^1.14.0", | ||
"@hotwax/dxp-components": "file:../dxp-components", | ||
"@hotwax/oms-api": "file:../oms-api", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. Use the latest oms-api version here. |
||
"@ionic/core": "^7.6.0", | ||
"@ionic/vue": "^7.6.0", | ||
"@ionic/vue-router": "^7.6.0", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,14 @@ import RootState from '@/store/RootState' | |
import OrderState from './OrderState' | ||
import * as types from './mutation-types' | ||
import { hasError, showToast } from '@/utils' | ||
import { getProductIdentificationValue, translate } from '@hotwax/dxp-components' | ||
import { getProductIdentificationValue, translate, useUserStore } from '@hotwax/dxp-components' | ||
import emitter from "@/event-bus"; | ||
import store from "@/store"; | ||
|
||
const getCurrentFacilityId = () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add a util function for this? |
||
const currentFacility: any = useUserStore().getCurrentFacility; | ||
return currentFacility?.facilityId | ||
} | ||
|
||
const actions: ActionTree<OrderState, RootState> = { | ||
|
||
|
@@ -73,6 +77,7 @@ const actions: ActionTree<OrderState, RootState> = { | |
|
||
const current = state.current as any | ||
const orders = state.purchaseOrders.list as any | ||
const currentFacilityId = getCurrentFacilityId(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the getCurrentFacilityId() directly if currentFacilityId is not reused. |
||
|
||
if (current.length && current[0]?.orderId === orderId) { return current } | ||
|
||
|
@@ -96,7 +101,7 @@ const actions: ActionTree<OrderState, RootState> = { | |
}, | ||
"query": "docType:ORDER", | ||
"filter": [ | ||
`orderTypeId: PURCHASE_ORDER AND orderId: ${orderId} AND orderStatusId: (ORDER_APPROVED OR ORDER_CREATED) AND facilityId: ${this.state.user.currentFacility.facilityId}` | ||
`orderTypeId: PURCHASE_ORDER AND orderId: ${orderId} AND orderStatusId: (ORDER_APPROVED OR ORDER_CREATED) AND facilityId: ${currentFacilityId}` | ||
] | ||
} | ||
} | ||
|
@@ -125,7 +130,7 @@ const actions: ActionTree<OrderState, RootState> = { | |
try { | ||
const params = { | ||
orderId: payload.orderId, | ||
facilityId: this.state.user.currentFacility.facilityId | ||
facilityId: getCurrentFacilityId() | ||
} | ||
|
||
resp = await OrderService.createPurchaseShipment(params) | ||
|
@@ -176,7 +181,8 @@ const actions: ActionTree<OrderState, RootState> = { | |
"fieldList": ["datetimeReceived", "productId", "quantityAccepted", "quantityRejected", "receivedByUserLoginId", "shipmentId", 'locationSeqId'], | ||
"orderBy": 'datetimeReceived DESC' | ||
} | ||
const facilityLocations = await this.dispatch('user/getFacilityLocations', this.state.user.currentFacility.facilityId); | ||
const currentFacilityId = getCurrentFacilityId() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the getCurrentFacilityId() directly if currentFacilityId is not reused. |
||
const facilityLocations = await this.dispatch('user/getFacilityLocations', currentFacilityId); | ||
const locationSeqId = facilityLocations.length > 0 ? facilityLocations[0].locationSeqId : ""; | ||
resp = await OrderService.fetchPOHistory(params) | ||
if (resp.status === 200 && !hasError(resp) && resp.data?.count > 0) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,15 @@ import RootState from '@/store/RootState' | |
import ShipmentState from './ShipmentState' | ||
import * as types from './mutation-types' | ||
import { hasError, showToast } from '@/utils' | ||
import { getProductIdentificationValue, translate } from '@hotwax/dxp-components' | ||
import { getProductIdentificationValue, translate, useUserStore } from '@hotwax/dxp-components' | ||
import emitter from '@/event-bus' | ||
import store from "@/store"; | ||
|
||
const getCurrentFacilityId = () => { | ||
const currentFacility: any = useUserStore().getCurrentFacility; | ||
return currentFacility?.facilityId | ||
} | ||
|
||
const actions: ActionTree<ShipmentState, RootState> = { | ||
async findShipment ({ commit, state }, payload) { | ||
if (payload.viewIndex === 0) emitter.emit("presentLoader"); | ||
|
@@ -69,8 +74,8 @@ 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 facilityLocations = await this.dispatch('user/getFacilityLocations', this.state.user.currentFacility.facilityId); | ||
const currentFacilityId = getCurrentFacilityId(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
const facilityLocations = await this.dispatch('user/getFacilityLocations', currentFacilityId); | ||
if(facilityLocations.length){ | ||
const locationSeqId = facilityLocations[0].locationSeqId | ||
resp.data.items.map((item: any) => { | ||
|
@@ -102,14 +107,15 @@ const actions: ActionTree<ShipmentState, RootState> = { | |
} | ||
}, | ||
receiveShipmentItem ({ commit }, payload) { | ||
const currentFacilityId = getCurrentFacilityId(); | ||
return Promise.all(payload.items.map(async (item: any) => { | ||
if(!item.locationSeqId) { | ||
return Promise.reject("Missing locationSeqId on item") | ||
} | ||
|
||
const params = { | ||
shipmentId: payload.shipmentId, | ||
facilityId: this.state.user.currentFacility.facilityId, | ||
facilityId: currentFacilityId, | ||
shipmentItemSeqId: item.itemSeqId, | ||
productId: item.productId, | ||
quantityAccepted: item.quantityAccepted, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,16 +5,15 @@ import UserState from './UserState' | |
import * as types from './mutation-types' | ||
import { hasError, showToast } from '@/utils' | ||
import { Settings } from 'luxon'; | ||
import { getUserFacilities, logout, updateInstanceUrl, updateToken, resetConfig } from '@/adapter' | ||
import { logout, updateInstanceUrl, updateToken, resetConfig } from '@/adapter' | ||
import { | ||
getServerPermissionsFromRules, | ||
prepareAppPermissions, | ||
resetPermissions, | ||
setPermissions | ||
} from '@/authorization' | ||
import { translate, useAuthStore, useProductIdentificationStore } from '@hotwax/dxp-components' | ||
import { translate, useAuthStore, useProductIdentificationStore, useUserStore } from '@hotwax/dxp-components' | ||
import emitter from '@/event-bus' | ||
import store from '@/store' | ||
|
||
const actions: ActionTree<UserState, RootState> = { | ||
|
||
|
@@ -57,8 +56,8 @@ const actions: ActionTree<UserState, RootState> = { | |
|
||
//fetching user facilities | ||
const isAdminUser = appPermissions.some((appPermission: any) => appPermission?.action === "APP_RECVG_ADMIN"); | ||
const baseURL = store.getters['user/getBaseUrl']; | ||
const facilities = await getUserFacilities(token, baseURL, userProfile?.partyId, "", isAdminUser); | ||
const facilities = await useUserStore().getUserFacilities(userProfile?.partyId, "", isAdminUser) | ||
await useUserStore().getFacilityPreference('SELECTED_FACILITY') | ||
|
||
if (!facilities.length) throw 'Unable to login. User is not assocaited with any facility' | ||
|
||
|
@@ -71,9 +70,8 @@ const actions: ActionTree<UserState, RootState> = { | |
return uniqueFacilities | ||
}, []); | ||
|
||
const currentFacility = userProfile.facilities[0]; | ||
const currentEComStore = await UserService.getEComStores(token, currentFacility.facilityId); | ||
|
||
const currentFacility: any = useUserStore().getCurrentFacility | ||
const currentEComStore = await UserService.getEComStores(token, currentFacility?.facilityId); | ||
const productStoreId = currentEComStore?.productStoreId; | ||
|
||
await useProductIdentificationStore().getIdentificationPref(productStoreId) | ||
|
@@ -87,7 +85,6 @@ const actions: ActionTree<UserState, RootState> = { | |
|
||
// TODO user single mutation | ||
commit(types.USER_INFO_UPDATED, userProfile); | ||
commit(types.USER_CURRENT_FACILITY_UPDATED, currentFacility); | ||
commit(types.USER_CURRENT_ECOM_STORE_UPDATED, currentEComStore); | ||
commit(types.USER_PERMISSIONS_UPDATED, appPermissions); | ||
commit(types.USER_TOKEN_CHANGED, { newToken: token }) | ||
|
@@ -173,12 +170,10 @@ const actions: ActionTree<UserState, RootState> = { | |
/** | ||
* update current facility information | ||
*/ | ||
async setFacility ({ commit, dispatch }, payload) { | ||
const eComStore = await UserService.getEComStores(undefined, payload.facility.facilityId); | ||
|
||
async setFacilityUpdates ({ commit, dispatch, state }, payload) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename payload to facilityId. |
||
const eComStore = await UserService.getEComStores(state.token, payload); | ||
commit(types.USER_CURRENT_ECOM_STORE_UPDATED, eComStore); | ||
commit(types.USER_CURRENT_FACILITY_UPDATED, payload.facility); | ||
await dispatch('getFacilityLocations', payload.facility.facilityId) | ||
await dispatch('getFacilityLocations', payload) | ||
}, | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Published the latest version of dxp-components. Please use the same here.