From 5a2a269f6788b57255daf8c71902d809f8dce006 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Tue, 16 Jan 2024 11:59:16 +0530 Subject: [PATCH 1/2] Implemented: support to fetch the routings for routingGroup(#21) --- src/router/index.ts | 5 ++-- src/services/RoutingService.ts | 9 ++++++ src/store/modules/orderRouting/actions.ts | 30 +++++++++++++++++++ src/store/modules/orderRouting/getters.ts | 3 ++ src/store/modules/orderRouting/index.ts | 2 +- .../modules/orderRouting/mutation-types.ts | 2 +- src/store/modules/orderRouting/mutations.ts | 2 +- src/views/BrokeringRoute.vue | 27 +++++++++++++---- src/views/BrokeringRuns.vue | 7 ++++- 9 files changed, 75 insertions(+), 12 deletions(-) diff --git a/src/router/index.ts b/src/router/index.ts index a24a30e..163ee06 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -38,8 +38,9 @@ const routes: Array = [ component: () => import("@/views/BrokeringRuns.vue") }, { - path: "brokering/route", - component: () => import("@/views/BrokeringRoute.vue") + path: "brokering/:routingGroupId/routes", + component: () => import("@/views/BrokeringRoute.vue"), + props: true }, { path: "brokering/query", diff --git a/src/services/RoutingService.ts b/src/services/RoutingService.ts index 1ee5ad8..f7d2acf 100644 --- a/src/services/RoutingService.ts +++ b/src/services/RoutingService.ts @@ -16,7 +16,16 @@ const createRoutingGroup = async (payload: any): Promise => { }) } +const fetchOrderRoutings = async (payload: any): Promise => { + return api({ + url: `groups/${payload.routingGroupId}/routings`, + method: "GET", + query: payload + }); +} + export const OrderRoutingService = { createRoutingGroup, + fetchOrderRoutings, fetchRoutingGroups } \ No newline at end of file diff --git a/src/store/modules/orderRouting/actions.ts b/src/store/modules/orderRouting/actions.ts index bf65483..f21c163 100644 --- a/src/store/modules/orderRouting/actions.ts +++ b/src/store/modules/orderRouting/actions.ts @@ -47,6 +47,36 @@ const actions: ActionTree = { showToast("Failed to create brokering run") logger.error('err', err) } + }, + + async setCurrentRoutingGroupId({ commit }, payload) { + commit(types.ORDER_ROUTING_CURRENT_GROUP_UPDATED, payload) + }, + + async fetchOrderRoutings({ commit }, routingGroupId) { + let orderRoutings = [] as any; + // filter groups on the basis of productStoreId + const payload = { + routingGroupId + } + + try { + const resp = await OrderRoutingService.fetchOrderRoutings(payload); + + if(!hasError(resp) && resp.data.length) { + orderRoutings = resp.data + } else { + throw resp.data + } + } catch(err) { + logger.error(err); + } + + if(orderRoutings.length) { + orderRoutings = sortSequence(orderRoutings) + } + + commit(types.ORDER_ROUTINGS_UPDATED, orderRoutings) } } diff --git a/src/store/modules/orderRouting/getters.ts b/src/store/modules/orderRouting/getters.ts index d4f946d..7271f81 100644 --- a/src/store/modules/orderRouting/getters.ts +++ b/src/store/modules/orderRouting/getters.ts @@ -5,6 +5,9 @@ import RootState from "@/store/RootState" const getters: GetterTree = { getRoutingGroups(state) { return state.groups + }, + getOrderRoutings(state) { + return state.routes } } diff --git a/src/store/modules/orderRouting/index.ts b/src/store/modules/orderRouting/index.ts index 09fa840..275bf06 100644 --- a/src/store/modules/orderRouting/index.ts +++ b/src/store/modules/orderRouting/index.ts @@ -11,7 +11,7 @@ const orderRoutingModule: Module = { groups: [], routes: [], rule: [], - currentGroupId: '', + currentGroupId: '', // choosing only to save id and not whole object, as when updating the state we don't need to care updating the state on two different places currentRouteId: '' }, getters, diff --git a/src/store/modules/orderRouting/mutation-types.ts b/src/store/modules/orderRouting/mutation-types.ts index 7f9cb71..4515191 100644 --- a/src/store/modules/orderRouting/mutation-types.ts +++ b/src/store/modules/orderRouting/mutation-types.ts @@ -1,6 +1,6 @@ export const SN_ORDER_ROUTING = "orderRouting" export const ORDER_ROUTING_GROUPS_UPDATED = SN_ORDER_ROUTING + "/GROUPS_UPDATED" -export const ORDER_ROUTING_ROUTES_UPDATED = SN_ORDER_ROUTING + "/ROUTES_UPDATED" +export const ORDER_ROUTINGS_UPDATED = SN_ORDER_ROUTING + "/ROUTES_UPDATED" export const ORDER_ROUTING_RULE_UPDATED = SN_ORDER_ROUTING + "/RULE_UPDATED" export const ORDER_ROUTING_CURRENT_GROUP_UPDATED = SN_ORDER_ROUTING + "/CURRENT_GROUP_UPDATED" export const ORDER_ROUTING_CURRENT_ROUTE_UPDATED = SN_ORDER_ROUTING + "/CURRENT_ROUTE_UPDATED" \ No newline at end of file diff --git a/src/store/modules/orderRouting/mutations.ts b/src/store/modules/orderRouting/mutations.ts index 4604a31..1667a59 100644 --- a/src/store/modules/orderRouting/mutations.ts +++ b/src/store/modules/orderRouting/mutations.ts @@ -6,7 +6,7 @@ const mutations: MutationTree = { [types.ORDER_ROUTING_GROUPS_UPDATED](state, payload) { state.groups = payload }, - [types.ORDER_ROUTING_ROUTES_UPDATED](state, payload) { + [types.ORDER_ROUTINGS_UPDATED](state, payload) { state.routes = payload }, [types.ORDER_ROUTING_RULE_UPDATED](state, payload) { diff --git a/src/views/BrokeringRoute.vue b/src/views/BrokeringRoute.vue index aa16573..dab2eea 100644 --- a/src/views/BrokeringRoute.vue +++ b/src/views/BrokeringRoute.vue @@ -18,15 +18,15 @@ - + -

{{ "Order lookup name" }}

+

{{ routing.routingName }}

- {{ `${card}/4` }} + {{ `${routing.sequenceNum}/4` }}
- - {{ "BADGE" }} + + {{ routing.statusId }} {{ "Archive" }} @@ -79,11 +79,26 @@