diff --git a/src/services/UtilService.ts b/src/services/UtilService.ts index 605bc52..1a04af3 100644 --- a/src/services/UtilService.ts +++ b/src/services/UtilService.ts @@ -8,6 +8,14 @@ const fetchEnums = async (payload: any): Promise => { }); } +const fetchOmsEnums = async (payload: any): Promise => { + return api({ + url: "omsenums", + method: "GET", + params: payload + }); +} + const fetchFacilities = async (payload: any): Promise => { return api({ url: "facilities", @@ -52,6 +60,7 @@ export const UtilService = { fetchEnums, fetchFacilities, fetchFacilityGroups, + fetchOmsEnums, fetchShippingMethods, fetchStatusInformation } \ No newline at end of file diff --git a/src/store/modules/util/actions.ts b/src/store/modules/util/actions.ts index 9c0e6d8..6c37f95 100644 --- a/src/store/modules/util/actions.ts +++ b/src/store/modules/util/actions.ts @@ -39,6 +39,36 @@ const actions: ActionTree = { 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)) diff --git a/src/views/BrokeringQuery.vue b/src/views/BrokeringQuery.vue index c36ef6a..8cad7a4 100644 --- a/src/views/BrokeringQuery.vue +++ b/src/views/BrokeringQuery.vue @@ -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.