Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,232 changes: 144 additions & 1,088 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"@capacitor/ios": "^2.5.0",
"@hotwax/app-version-info": "^1.0.0",
"@hotwax/apps-theme": "^1.2.6",
"@hotwax/dxp-components": "^1.12.2",
"@hotwax/oms-api": "^1.13.0",
"@hotwax/dxp-components": "file:../dxp-components",
"@hotwax/oms-api": "file:../oms-api",
"@ionic/core": "~7.6.0",
"@ionic/vue": "~7.6.0",
"@ionic/vue-router": "~7.6.0",
Expand Down
5 changes: 4 additions & 1 deletion src/adapter/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { api, client, getConfig, getProductIdentificationPref, hasError, initialise, logout, resetConfig, setProductIdentificationPref, updateInstanceUrl, updateToken } from '@hotwax/oms-api'
import { api, client, getConfig, getUserFacilities, getUserPreference, getProductIdentificationPref, hasError, initialise, logout, resetConfig, setProductIdentificationPref, setUserPreference, updateInstanceUrl, updateToken } from '@hotwax/oms-api'

export {
api,
client,
getConfig,
getProductIdentificationPref,
getUserFacilities,
getUserPreference,
hasError,
initialise,
logout,
resetConfig,
setProductIdentificationPref,
setUserPreference,
updateInstanceUrl,
updateToken
}
3 changes: 3 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"Error getting user profile.": "Error getting user profile.",
"Facility": "Facility",
"Fetching time zones": "Fetching time zones",
"Fetching facilities": "Fetching facilities",
"Filters": "Filters",
"Go to OMS": "Go to OMS",
"Go to Launchpad": "Go to Launchpad",
Expand All @@ -32,6 +33,7 @@
"Logging in": "Logging in",
"Logging out": "Logging out",
"Logout": "Logout",
"No facilities found": "No facilities found",
"No item has been picked": "No item has been picked",
"No permission": "No permission",
"No picklist found": "No picklist found",
Expand All @@ -51,6 +53,7 @@
"Product not found in remaining items": "Product not found in remaining items",
"Reason:": "Reason:",
"Scan": "Scan",
"Search facilities": "Search facilities",
"Search time zones": "Search time zones",
"Secondary": "Secondary",
"Select all" : "Select all",
Expand Down
7 changes: 5 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import i18n from './i18n'
import store from './store'
import { dxpComponents } from '@hotwax/dxp-components'
import { login, logout, loader } from './user-utils';
import { getConfig, getProductIdentificationPref, initialise, setProductIdentificationPref } from '@/adapter'
import { getConfig, getProductIdentificationPref, getUserFacilities, getUserPreference, initialise, setProductIdentificationPref, setUserPreference } from '@/adapter'
import localeMessages from './locales';

const app = createApp(App)
Expand All @@ -50,7 +50,10 @@ const app = createApp(App)
getProductIdentificationPref,
initialise,
setProductIdentificationPref,
localeMessages
localeMessages,
getUserFacilities,
setUserPreference,
getUserPreference
});

// Filters are removed in Vue 3 and global filter introduced https://v3.vuejs.org/guide/migration/filters.html#global-filters
Expand Down
10 changes: 8 additions & 2 deletions src/store/modules/picklist/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import { PicklistService } from '@/services/PicklistService'
import { showToast } from '@/utils'
import { hasError } from '@/adapter'
import { translate } from '@/i18n'
import { useUserStore } from '@hotwax/dxp-components'

const getCurrentFacilityId = () => {
const currentFacility: any = useUserStore().getCurrentFacility;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Directly use useUserStore().getCurrentFacility wherever required as we only have a couple of places where this data is used.

return currentFacility?.facilityId
}

const actions: ActionTree<PicklistState, RootState> = {
/**
Expand All @@ -16,7 +22,7 @@ const actions: ActionTree<PicklistState, RootState> = {
const params = {
"inputFields": {
"statusId": "PICKLIST_PRINTED",
"facilityId": this.state.user.currentFacility.facilityId,
"facilityId": getCurrentFacilityId(),
},
"orderBy": "picklistDate DESC",
"viewSize": payload.viewSize,
Expand Down Expand Up @@ -57,7 +63,7 @@ const actions: ActionTree<PicklistState, RootState> = {
"inputFields": {
"statusId": ["PICKLIST_COMPLETED", "PICKLIST_PICKED"],
"statusId_op": "in",
"facilityId": this.state.user.currentFacility.facilityId,
"facilityId": getCurrentFacilityId(),
},
"orderBy": "picklistDate DESC",
"viewSize": 10,
Expand Down
1 change: 0 additions & 1 deletion src/store/modules/user/UserState.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export default interface UserState {
token: string;
current: object | null;
currentFacility: object;
instanceUrl: string;
picklistItemSortBy: string;
pwaState: any;
Expand Down
15 changes: 6 additions & 9 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { showToast } from '@/utils'
import { translate } from '@/i18n'
import { Settings } from 'luxon';
import { hasError, logout, updateInstanceUrl, updateToken, resetConfig } from '@/adapter'
import { useAuthStore, useProductIdentificationStore } from '@hotwax/dxp-components'
import { useAuthStore, useProductIdentificationStore, useUserStore } from '@hotwax/dxp-components'
import emitter from '@/event-bus'
import router from '@/router';

Expand Down Expand Up @@ -123,10 +123,10 @@ const actions: ActionTree<UserState, RootState> = {
}
commit(types.USER_INFO_UPDATED, resp.data);

const currentFacility = resp.data.facilities.length > 0 ? resp.data.facilities[0] : {};

commit(types.USER_CURRENT_FACILITY_UPDATED, currentFacility);
await useUserStore().getUserFacilities(resp.data.partyId, "", false)
await useUserStore().getFacilityPreference('SELECTED_FACILITY')

const currentFacility: any = useUserStore().getCurrentFacility
// get and set current ecom store in state
const currentEComStore = await UserService.getCurrentEComStore(token, currentFacility?.facilityId);
commit(types.USER_CURRENT_ECOM_STORE_UPDATED, currentEComStore);
Expand All @@ -151,12 +151,9 @@ const actions: ActionTree<UserState, RootState> = {
}
},

// update current facility information
async setFacility ({ commit, state }, payload) {
commit(types.USER_CURRENT_FACILITY_UPDATED, payload.facility);

async setFacilityUpdates ({ commit, state }, payload) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
async setFacilityUpdates ({ commit, state }, payload) {
async setFacility({ commit, state }, payload) {

Improve indentation

// get and set current ecom store in state
const currentEComStore = await UserService.getCurrentEComStore(state.token, payload.facility.facilityId);
const currentEComStore = await UserService.getCurrentEComStore(state.token, payload);
commit(types.USER_CURRENT_ECOM_STORE_UPDATED, currentEComStore);

await useProductIdentificationStore().getIdentificationPref(currentEComStore?.productStoreId)
Expand Down
3 changes: 0 additions & 3 deletions src/store/modules/user/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ const getters: GetterTree <UserState, RootState> = {
getCurrentEComStore(state) {
return state.currentEComStore;
},
getCurrentFacility (state) {
return state.currentFacility;
},
getInstanceUrl (state) {
const baseUrl = process.env.VUE_APP_BASE_URL;
return baseUrl ? baseUrl : state.instanceUrl;
Expand Down
1 change: 0 additions & 1 deletion src/store/modules/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const userModule: Module<UserState, RootState> = {
token: '',
current: null,
currentEComStore: {},
currentFacility: {},
instanceUrl: '',
picklistItemSortBy: 'productName',
pwaState: {
Expand Down
1 change: 0 additions & 1 deletion src/store/modules/user/mutation-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export const SN_USER = 'user'
export const USER_TOKEN_CHANGED = SN_USER + '/TOKEN_CHANGED'
export const USER_END_SESSION = SN_USER + '/END_SESSION'
export const USER_INFO_UPDATED = SN_USER + '/INFO_UPDATED'
export const USER_CURRENT_FACILITY_UPDATED = SN_USER + '/CURRENT_FACILITY_UPDATED'
export const USER_INSTANCE_URL_UPDATED = SN_USER + '/INSTANCE_URL_UPDATED'
export const USER_SORTBY_UPDATED = SN_USER + '/SORTBY_UPDATED'
export const USER_PWA_STATE_UPDATED = SN_USER + '/PWA_STATE_UPDATED'
Expand Down
4 changes: 0 additions & 4 deletions src/store/modules/user/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ const mutations: MutationTree <UserState> = {
[types.USER_END_SESSION] (state) {
state.token = ''
state.current = null
state.currentFacility = {}
},
[types.USER_INFO_UPDATED] (state, payload) {
state.current = payload
},
[types.USER_CURRENT_FACILITY_UPDATED] (state, payload) {
state.currentFacility = payload;
},
[types.USER_INSTANCE_URL_UPDATED] (state, payload) {
state.instanceUrl = payload;
},
Expand Down
28 changes: 3 additions & 25 deletions src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,7 @@
</div>
<section>
<DxpOmsInstanceNavigator />

<ion-card>
<ion-card-header>
<ion-card-title>
{{ $t("Facility") }}
</ion-card-title>
</ion-card-header>
<ion-card-content>
{{ $t('Specify which facility you want to operate from. Order, inventory and other configuration data will be specific to the facility you select.') }}
</ion-card-content>
<ion-item lines="none">
<ion-select :label="$t('Select facility')" interface="popover" :value="currentFacility.facilityId" @ionChange="setFacility($event)">
<ion-select-option v-for="facility in (userProfile ? userProfile.facilities : [])" :key="facility.facilityId" :value="facility.facilityId" >{{ facility.name }}</ion-select-option>
</ion-select>
</ion-item>
</ion-card>
<DxpFacilitySwitcher @updateFacility="handleFacilityUpdate($event)"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<DxpFacilitySwitcher @updateFacility="handleFacilityUpdate($event)"/>
<DxpFacilitySwitcher @updateFacility="updateFacility(facility)"/>

</section>
<hr />

Expand Down Expand Up @@ -132,7 +117,6 @@ export default defineComponent({
computed: {
...mapGetters({
userProfile: 'user/getUserProfile',
currentFacility: 'user/getCurrentFacility',
uploadProducts: 'product/getUploadProducts',
picklistItemSortBy: 'user/getPicklistItemSortBy'
})
Expand All @@ -156,14 +140,8 @@ export default defineComponent({
}
})
},
setFacility (facility: any) {
if (this.userProfile){
this.userProfile.facilities.map((fac: any) => {
if (fac.facilityId == facility['detail'].value) {
this.store.dispatch('user/setFacility', {'facility': fac});
}
})
}
async handleFacilityUpdate(selectedFacility: any) {
await this.store.dispatch('user/setFacilityUpdates', selectedFacility?.facilityId);
},
goToLaunchpad() {
window.location.href = `${process.env.VUE_APP_LOGIN_URL}`
Expand Down