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

Fixed: case to update current group state when making any change on group level #35

Merged
merged 1 commit into from
Jan 20, 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
22 changes: 9 additions & 13 deletions src/store/modules/orderRouting/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { hasError, showToast, sortSequence } from "@/utils"
import * as types from './mutation-types'
import logger from "@/logger"
import { Group, Route, RouteFilter } from "@/types"

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

'Group' is defined but never used

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

'Group' is defined but never used

const actions: ActionTree<OrderRoutingState, RootState> = {
async fetchOrderRoutingGroups({ commit }) {
Expand Down Expand Up @@ -51,30 +51,26 @@
},

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 @@ -105,7 +105,7 @@
import { addCircleOutline, archiveOutline, reorderTwoOutline, saveOutline, timeOutline, timerOutline } from "ionicons/icons"
import { useRouter } from "vue-router";
import { useStore } from "vuex";
import { computed, defineProps, onMounted, ref } from "vue";

Check warning on line 108 in src/views/BrokeringRoute.vue

View workflow job for this annotation

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

'onMounted' is defined but never used

Check warning on line 108 in src/views/BrokeringRoute.vue

View workflow job for this annotation

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

'onMounted' is defined but never used
import { Group, Route } from "@/types";
import ArchivedRoutingModal from "@/components/ArchivedRoutingModal.vue"
import emitter from "@/event-bus";
Expand Down Expand Up @@ -207,12 +207,7 @@

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
Loading