From 8496f851721932385e5297bebda6a99fb9cf9d90 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Tue, 2 Jul 2024 14:46:24 +0530 Subject: [PATCH 1/2] Improved: endpoint for fetching enums related to sales channel(#235) --- src/store/modules/util/actions.ts | 30 ++++++++++++++++++++++++++++++ src/views/BrokeringQuery.vue | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) 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. From e2982dd302a89a26dd1594a169d47b8e679e401c Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Tue, 2 Jul 2024 14:58:16 +0530 Subject: [PATCH 2/2] Fixed: issue of missing export from util service(#235) --- src/services/UtilService.ts | 9 +++++++++ 1 file changed, 9 insertions(+) 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