Skip to content

Commit

Permalink
Merge pull request #236 from ymaheshwari1/#235
Browse files Browse the repository at this point in the history
Improved: endpoint for fetching enums related to sales channel(#235)
  • Loading branch information
ymaheshwari1 authored Jul 2, 2024
2 parents 78673ba + e2982dd commit 883e3f2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/services/UtilService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ const fetchEnums = async (payload: any): Promise<any> => {
});
}

const fetchOmsEnums = async (payload: any): Promise<any> => {
return api({
url: "omsenums",
method: "GET",
params: payload
});
}

const fetchFacilities = async (payload: any): Promise<any> => {
return api({
url: "facilities",
Expand Down Expand Up @@ -52,6 +60,7 @@ export const UtilService = {
fetchEnums,
fetchFacilities,
fetchFacilityGroups,
fetchOmsEnums,
fetchShippingMethods,
fetchStatusInformation
}
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 883e3f2

Please sign in to comment.