Skip to content

Commit

Permalink
Implemented: support to display good identification options dynamical…
Browse files Browse the repository at this point in the history
…ly(dxp/345)
  • Loading branch information
ymaheshwari1 committed Oct 25, 2024
1 parent 3d05506 commit 3959562
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 8 deletions.
17 changes: 17 additions & 0 deletions src/services/UserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,29 @@ const getFieldMappings = async (payload: any): Promise <any> => {
});
}

const fetchGoodIdentificationTypes = async (payload: any): Promise <any> => {
const omsRedirectionInfo = store.getters["user/getOmsRedirectionInfo"]
const baseURL = omsRedirectionInfo.url.startsWith('http') ? omsRedirectionInfo.url.includes('/api') ? omsRedirectionInfo.url : `${omsRedirectionInfo.url}/api/` : `https://${omsRedirectionInfo.url}.hotwax.io/api/`;

return await client({
url: "performFind",
method: "post",
baseURL,
data: payload,
headers: {
"Authorization": 'Bearer ' + omsRedirectionInfo.token,
'Content-Type': 'application/json'
}
});
}

export const UserService = {
createFieldMapping,
createProductStoreSetting,
deleteFieldMapping,
fetchAssociatedFacilities,
fetchFacilities,
fetchGoodIdentificationTypes,
fetchProductStores,
fetchProductStoreSettings,
getAvailableTimeZones,
Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/product/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const actions: ActionTree<ProductState, RootState> = {

async clearProducts({ commit }) {
commit(types.PRODUCT_LIST_UPDATED, { products: [], total: 0 });
}
}
}

export default actions;
5 changes: 3 additions & 2 deletions src/store/modules/user/UserState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default interface UserState {
productIdentificationPref: {
primaryId: string,
secondaryId: string
}
}
},
},
goodIdentificationTypes: Array<string>;
}
26 changes: 26 additions & 0 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const actions: ActionTree<UserState, RootState> = {
primaryId: 'productId',
secondaryId: ''
}})
commit(types.USER_GOOD_IDENTIFICATION_TYPES_UPDATED, [])
this.dispatch('count/clearCycleCounts')
this.dispatch('count/clearCycleCountItems')

Expand Down Expand Up @@ -545,6 +546,31 @@ const actions: ActionTree<UserState, RootState> = {
name: '',
value: {}
})
},

async fetchGoodIdentificationTypes({ commit }, parentTypeId = "HC_GOOD_ID_TYPE") {
let identificationTypes = process.env.VUE_APP_PRDT_IDENT ? JSON.parse(process.env.VUE_APP_PRDT_IDENT) : []
const payload = {
"inputFields": {
parentTypeId
},
"fieldList": ["goodIdentificationTypeId", "description"],
"viewSize": 50,
"entityName": "GoodIdentificationType",
}
try {
const resp = await UserService.fetchGoodIdentificationTypes(payload)
if (!hasError(resp) && resp.data?.docs?.length) {
const identificationOptions = resp.data.docs?.map((fetchedGoodIdentificationType: any) => fetchedGoodIdentificationType.goodIdentificationTypeId) || [];
// Merge the arrays and remove duplicates
identificationTypes = Array.from(new Set([...identificationOptions, ...identificationTypes])).sort();
} else {
throw resp.data;
}
} catch (err) {
console.error('Failed to fetch the good identification types, setting default types')
}
commit(types.USER_GOOD_IDENTIFICATION_TYPES_UPDATED, identificationTypes)
}
}
export default actions;
3 changes: 3 additions & 0 deletions src/store/modules/user/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ const getters: GetterTree <UserState, RootState> = {
return fieldMapping ? fieldMapping : {}
}
return state.fieldMappings;
},
getGoodIdentificationTypes(state) {
return state.goodIdentificationTypes;
}
}
export default getters;
3 changes: 2 additions & 1 deletion src/store/modules/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ const userModule: Module<UserState, RootState> = {
primaryId: 'productId',
secondaryId: ''
},
}
},
goodIdentificationTypes: []
},
getters,
actions,
Expand Down
3 changes: 2 additions & 1 deletion src/store/modules/user/mutation-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export const USER_CURRENT_PRODUCT_STORE_UPDATED = SN_USER + '/CURRENT_PRODUCT_ST
export const USER_PRODUCT_STORE_SETTING_UPDATED = SN_USER + '/PRODUCT_STORE_SETTING_UPDATED'
export const USER_FIELD_MAPPINGS_UPDATED = SN_USER + '/FIELD_MAPPINGS_UPDATED'
export const USER_FIELD_MAPPING_CREATED = SN_USER + '/FIELD_MAPPING_CREATED'
export const USER_CURRENT_FIELD_MAPPING_UPDATED = SN_USER + '/_CURRENT_FIELD_MAPPING_UPDATED'
export const USER_CURRENT_FIELD_MAPPING_UPDATED = SN_USER + '/_CURRENT_FIELD_MAPPING_UPDATED'
export const USER_GOOD_IDENTIFICATION_TYPES_UPDATED = SN_USER + '/PRODUCT_IDENTIFICATION_OPTIONS_UPDATED'
3 changes: 3 additions & 0 deletions src/store/modules/user/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ const mutations: MutationTree <UserState> = {
name: payload.name,
value: payload.value
};
},
[types.USER_GOOD_IDENTIFICATION_TYPES_UPDATED](state, payload = []) {
state.goodIdentificationTypes = payload.length ? payload : process.env.VUE_APP_PRDT_IDENT ? JSON.parse(process.env.VUE_APP_PRDT_IDENT) : []
}
}
export default mutations;
6 changes: 3 additions & 3 deletions src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ const store = useStore()
const appVersion = ref("")
const appInfo = (process.env.VUE_APP_VERSION_INFO ? JSON.parse(process.env.VUE_APP_VERSION_INFO) : {}) as any
const productIdentifications = process.env.VUE_APP_PRDT_IDENT ? JSON.parse(process.env.VUE_APP_PRDT_IDENT) : []
const userProfile = computed(() => store.getters["user/getUserProfile"])
const oms = computed(() => store.getters["user/getInstanceUrl"])
const omsRedirectionInfo = computed(() => store.getters["user/getOmsRedirectionInfo"])
Expand All @@ -163,9 +161,11 @@ const currentFacility = computed(() => store.getters["user/getCurrentFacility"])
const currentProductStore = computed(() => store.getters["user/getCurrentProductStore"])
const productStores = computed(() => store.getters["user/getProductStores"])
const productStoreSettings = computed(() => store.getters["user/getProductStoreSettings"])
const productIdentifications = computed(() => store.getters["user/getGoodIdentificationTypes"])
onMounted(() => {
onMounted(async () => {
appVersion.value = appInfo.branch ? (appInfo.branch + "-" + appInfo.revision) : appInfo.tag;
await store.dispatch("user/fetchGoodIdentificationTypes")
})
function logout() {
Expand Down

0 comments on commit 3959562

Please sign in to comment.