Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved: the endpoint to fetch the schedule information for a group(#51) #55

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
}
},

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 / 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 @@
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 Expand Up @@ -141,7 +161,7 @@
commit(types.ORDER_ROUTING_CURRENT_ROUTE_UPDATED, payload)
},

async deleteRoutingFilters({ dispatch }, payload) {

Check warning on line 164 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)

'dispatch' is defined but never used

Check warning on line 164 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)

'dispatch' is defined but never used
let hasAllFiltersDeletedSuccessfully = true;
try {
// As discussed, we can't make parallel api calls, hence using for loop to make api calls
Expand All @@ -161,7 +181,7 @@
return hasAllFiltersDeletedSuccessfully
},

async updateRouting({ dispatch }, payload) {

Check warning on line 184 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)

'dispatch' is defined but never used

Check warning on line 184 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)

'dispatch' is defined but never used
let orderRoutingId = ''
try {
const resp = await OrderRoutingService.updateRouting(payload)
Expand Down Expand Up @@ -208,7 +228,7 @@
return routingRuleId;
},

async deleteRuleConditions({ dispatch }, payload) {

Check warning on line 231 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)

'dispatch' is defined but never used

Check warning on line 231 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)

'dispatch' is defined but never used
// TODO: check if we can call request in parallel for delete operation
let hasAllConditionsDeletedSuccessfully = true;
try {
Expand All @@ -228,7 +248,7 @@
return hasAllConditionsDeletedSuccessfully
},

async deleteRuleActions({ dispatch }, payload) {

Check warning on line 251 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)

'dispatch' is defined but never used

Check warning on line 251 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)

'dispatch' is defined but never used
// TODO: check if we can call request in parallel for delete operation
let hasAllActionsDeletedSuccessfully = true;
try {
Expand Down Expand Up @@ -291,7 +311,7 @@
return JSON.parse(JSON.stringify(rulesInformation[routingRuleId]))
},

async updateRule({ dispatch }, payload) {

Check warning on line 314 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)

'dispatch' is defined but never used

Check warning on line 314 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)

'dispatch' is defined but never used
let routingRuleId = ''
try {
const resp = await OrderRoutingService.updateRule(payload)
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
Loading