diff --git a/src/services/RoutingService.ts b/src/services/RoutingService.ts index 7d650bc..ca866ad 100644 --- a/src/services/RoutingService.ts +++ b/src/services/RoutingService.ts @@ -15,6 +15,13 @@ const fetchRoutingGroupInformation = async (routingGroupId: string): Promise => { + return api({ + url: `groups/${routingGroupId}/schedule`, + method: "GET" + }); +} + const createRoutingGroup = async (payload: any): Promise => { return api({ url: "groups", @@ -119,6 +126,7 @@ export const OrderRoutingService = { fetchOrderRouting, fetchRoutingGroupInformation, fetchRoutingGroups, + fetchRoutingScheduleInformation, fetchRule, scheduleBrokering, updateRouting, diff --git a/src/store/modules/orderRouting/actions.ts b/src/store/modules/orderRouting/actions.ts index bf6eb73..5921d21 100644 --- a/src/store/modules/orderRouting/actions.ts +++ b/src/store/modules/orderRouting/actions.ts @@ -54,7 +54,7 @@ const actions: ActionTree = { } }, - async fetchCurrentRoutingGroup({ commit }, routingGroupId) { + async fetchCurrentRoutingGroup({ commit, dispatch }, routingGroupId) { emitter.emit("presentLoader", { message: "Fetching rules", backdropDismiss: false }) let currentGroup = {} as any @@ -74,10 +74,30 @@ const actions: ActionTree = { currentGroup.routings = sortSequence(currentGroup.routings) } - commit(types.ORDER_ROUTING_CURRENT_GROUP_UPDATED, currentGroup) + // Fetching the schedule information for the group + await dispatch("fetchCurrentGroupSchedule", { routingGroupId, currentGroup }) + emitter.emit("dismissLoader") }, + async fetchCurrentGroupSchedule({ commit }, payload) { + const currentGroup = payload.currentGroup as any + + try { + const resp = await OrderRoutingService.fetchRoutingScheduleInformation(payload.routingGroupId); + + if(!hasError(resp) && resp.data?.schedule) { + currentGroup["schedule"] = resp.data.schedule + } else { + throw resp.data + } + } catch(err) { + logger.error(err); + } + + commit(types.ORDER_ROUTING_CURRENT_GROUP_UPDATED, currentGroup) + }, + async setCurrentGroup({ commit }, currentGroup) { commit(types.ORDER_ROUTING_CURRENT_GROUP_UPDATED, currentGroup) }, diff --git a/src/store/modules/orderRouting/index.ts b/src/store/modules/orderRouting/index.ts index efa0196..91c96f6 100644 --- a/src/store/modules/orderRouting/index.ts +++ b/src/store/modules/orderRouting/index.ts @@ -4,7 +4,6 @@ import mutations from "./mutations" import { Module } from "vuex" import OrderRoutingState from "./OrderRoutingState" import RootState from "@/store/RootState" -import { Route } from "@/types" const orderRoutingModule: Module = { namespaced: true,