Skip to content

Commit

Permalink
Merge pull request #55 from ymaheshwari1/#51
Browse files Browse the repository at this point in the history
Improved: the endpoint to fetch the schedule information for a group(#51)
  • Loading branch information
ymaheshwari1 authored Jan 31, 2024
2 parents a68afc6 + 6446b1d commit f082593
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/services/RoutingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ const fetchRoutingGroupInformation = async (routingGroupId: string): Promise<any
});
}

const fetchRoutingScheduleInformation = async (routingGroupId: string): Promise<any> => {
return api({
url: `groups/${routingGroupId}/schedule`,
method: "GET"
});
}

const createRoutingGroup = async (payload: any): Promise<any> => {
return api({
url: "groups",
Expand Down Expand Up @@ -119,6 +126,7 @@ export const OrderRoutingService = {
fetchOrderRouting,
fetchRoutingGroupInformation,
fetchRoutingGroups,
fetchRoutingScheduleInformation,
fetchRule,
scheduleBrokering,
updateRouting,
Expand Down
24 changes: 22 additions & 2 deletions src/store/modules/orderRouting/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const actions: ActionTree<OrderRoutingState, RootState> = {
}
},

async fetchCurrentRoutingGroup({ commit }, routingGroupId) {
async fetchCurrentRoutingGroup({ commit, dispatch }, routingGroupId) {

Check warning on line 57 in src/store/modules/orderRouting/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'commit' is defined but never used

Check warning on line 57 in src/store/modules/orderRouting/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / build_and_deploy

'commit' is defined but never used

Check warning on line 57 in src/store/modules/orderRouting/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'commit' is defined but never used
emitter.emit("presentLoader", { message: "Fetching rules", backdropDismiss: false })
let currentGroup = {} as any

Expand All @@ -74,10 +74,30 @@ const actions: ActionTree<OrderRoutingState, RootState> = {
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)
},
Expand Down
1 change: 0 additions & 1 deletion src/store/modules/orderRouting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<OrderRoutingState, RootState> = {
namespaced: true,
Expand Down

0 comments on commit f082593

Please sign in to comment.