From 648546888d92d8146d7448ab2115a99ca6646f61 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 13 Jun 2024 14:56:19 +0200 Subject: [PATCH] fix: DeleteDepartment VnConfirm --- src/pages/Worker/WorkerDepartmentTree.vue | 36 ++++++++++++----------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/pages/Worker/WorkerDepartmentTree.vue b/src/pages/Worker/WorkerDepartmentTree.vue index 34340b019..392539c86 100644 --- a/src/pages/Worker/WorkerDepartmentTree.vue +++ b/src/pages/Worker/WorkerDepartmentTree.vue @@ -6,12 +6,11 @@ import { useQuasar } from 'quasar'; import DepartmentDescriptorProxy from 'src/pages/Department/Card/DepartmentDescriptorProxy.vue'; import CreateDepartmentChild from './CreateDepartmentChild.vue'; import axios from 'axios'; -import useNotify from 'src/composables/useNotify.js'; import { useRouter } from 'vue-router'; +import VnConfirm from 'src/components/ui/VnConfirm.vue'; const quasar = useQuasar(); const { t } = useI18n(); -const { notify } = useNotify(); const state = useState(); const router = useRouter(); @@ -62,25 +61,28 @@ const removeNode = (node) => { const { id, parentFk } = node; quasar .dialog({ - title: t('Are you sure you want to delete it?'), - message: t('Delete department'), - ok: { - push: true, - color: 'primary', + component: VnConfirm, + componentProps: { + title: t('Are you sure you want to delete it?'), + message: t('Delete department'), + promise: () => remove(id), }, - cancel: true, }) - .onOk(async () => { - try { - await axios.post(`/Departments/${id}/removeChild`, id); - notify(t('department.departmentRemoved'), 'positive'); - await fetchNodeLeaves(parentFk); - } catch (err) { - console.error('Error removing department'); - } - }); + .onOk(async () => await fetchNodeLeaves(parentFk)); }; +async function remove(id) { + try { + await axios.post(`/Departments/${id}/removeChild`, { id }); + quasar.notify({ + message: t('department.departmentRemoved'), + type: 'positive', + }); + } catch (err) { + console.error('Error removing department'); + } +} + const showCreateNodeForm = (nodeId) => { showCreateNodeFormVal.value = true; creationNodeSelectedId.value = nodeId;