Skip to content

Commit

Permalink
Fixed: case to update current state when making any change on group l…
Browse files Browse the repository at this point in the history
…evel
  • Loading branch information
ymaheshwari1 committed Jan 20, 2024
1 parent b7bd5e7 commit d746c0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
22 changes: 9 additions & 13 deletions src/store/modules/orderRouting/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,30 +51,26 @@ const actions: ActionTree<OrderRoutingState, RootState> = {
},

async updateRoutingGroup({ commit, state }, payload) {
let routingGroups = JSON.parse(JSON.stringify(state.groups))
const current = JSON.parse(JSON.stringify(state.currentGroup))

const params = {
routingGroupId: payload.routingGroupId,
[payload.fieldToUpdate]: payload.value
}

try {
const resp = await OrderRoutingService.updateRoutingGroup(payload);
const resp = await OrderRoutingService.updateRoutingGroup(params);

if(!hasError(resp) && resp.data.routingGroupId) {
routingGroups.map((group: Group) => {
if(group.routingGroupId === resp.data.routingGroupId) {
group.description = payload.description
}
})
current[payload.fieldToUpdate] = payload.value
showToast("Rounting group information updated")
} else {
throw resp.data
}
} catch(err) {
logger.error(err);
}

if(routingGroups.length) {
routingGroups = sortSequence(routingGroups)
}

commit(types.ORDER_ROUTING_GROUPS_UPDATED, routingGroups)
commit(types.ORDER_ROUTING_CURRENT_GROUP_UPDATED, current)
},

async fetchCurrentRoutingGroup({ dispatch, state }, routingGroupId) {
Expand Down
7 changes: 1 addition & 6 deletions src/views/BrokeringRoute.vue
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,7 @@ function getArchivedOrderRoutings() {
async function updateGroupDescription() {
if(description.value && props.routingGroupId) {
const payload = {
routingGroupId: props.routingGroupId,
description: description.value,
}
await store.dispatch("orderRouting/updateRoutingGroup", payload)
await store.dispatch("orderRouting/updateRoutingGroup", { routingGroupId: props.routingGroupId, fieldToUpdate: 'description', value: description.value })
isDescUpdating.value = false
}
}
Expand Down

0 comments on commit d746c0e

Please sign in to comment.