Skip to content

Commit

Permalink
Improved: endpoint for fetching enums related to sales channel(#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
ymaheshwari1 committed Jul 2, 2024
1 parent 78673ba commit 8496f85
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
30 changes: 30 additions & 0 deletions src/store/modules/util/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,36 @@ const actions: ActionTree<UtilState, RootState> = {
commit(types.UTIL_ENUMS_UPDATED, enums)
},

async fetchOmsEnums({ commit, state }, payload) {
let enums = {
...state.enums
}

try {
const resp = await UtilService.fetchOmsEnums({
...payload,
pageSize: 500
});

if(!hasError(resp) && resp.data.length) {
enums = resp.data.reduce((enumerations: any, data: EnumerationAndType) => {
if(enumerations[data.enumTypeId]) {
enumerations[data.enumTypeId][data.enumId] = data
} else {
enumerations[data.enumTypeId] = {
[data.enumId]: data
}
}
return enumerations
}, enums)
}
} catch(err) {
logger.error(err)
}

commit(types.UTIL_ENUMS_UPDATED, enums)
},

async fetchFacilities({ commit, state }) {
let facilities = JSON.parse(JSON.stringify(state.facilities))

Expand Down
2 changes: 1 addition & 1 deletion src/views/BrokeringQuery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ const ruleNameRef = ref()
onIonViewWillEnter(async () => {
emitter.emit("presentLoader", { message: "Fetching filters and inventory rules", backdropDismiss: false })
await Promise.all([store.dispatch("orderRouting/fetchCurrentOrderRouting", props.orderRoutingId), store.dispatch("util/fetchFacilities"), store.dispatch("util/fetchEnums", { enumTypeId: "ORDER_SALES_CHANNEL" }), store.dispatch("util/fetchShippingMethods"), store.dispatch("util/fetchFacilityGroups")])
await Promise.all([store.dispatch("orderRouting/fetchCurrentOrderRouting", props.orderRoutingId), store.dispatch("util/fetchFacilities"), store.dispatch("util/fetchOmsEnums", { enumTypeId: "ORDER_SALES_CHANNEL" }), store.dispatch("util/fetchShippingMethods"), store.dispatch("util/fetchFacilityGroups")])
store.dispatch("orderRouting/fetchRoutingHistory", router.currentRoute.value.params.routingGroupId)
// Fetching the group information again if the group stored in the state and the groupId in the route params are not same. This case occurs when we are on the route details page of a group and then directly hit the route details for a different group.
Expand Down

0 comments on commit 8496f85

Please sign in to comment.