From a9d58748fec2239ddb4f757c0a3481dade06e36c Mon Sep 17 00:00:00 2001 From: Net Date: Thu, 15 Aug 2024 09:57:02 +0700 Subject: [PATCH] refactor: delete btn test --- .../03_customer-management/BranchPage.vue | 45 +++++++++++++------ 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/src/pages/03_customer-management/BranchPage.vue b/src/pages/03_customer-management/BranchPage.vue index bb79f8c5..1e94cd98 100644 --- a/src/pages/03_customer-management/BranchPage.vue +++ b/src/pages/03_customer-management/BranchPage.vue @@ -7,7 +7,9 @@ import useOptionStore from 'stores/options'; import { Status } from 'stores/types'; import { CustomerBranch, CustomerType } from 'stores/customer/types'; +import { useI18n } from 'vue-i18n'; +import { dialog } from 'stores/utils'; import ButtonAddComponent from 'components/ButtonAddCompoent.vue'; import SideMenu from 'components/SideMenu.vue'; import { DialogFormContainer, DialogHeader } from 'components/dialog'; @@ -32,6 +34,7 @@ import { } from './components'; const flowStore = useFlowStore(); +const { t } = useI18n(); const customerStore = useCustomerStore(); const { fetchListCustomeBranch } = customerStore; @@ -141,6 +144,29 @@ const branchFieldSelected = ref< )[] >(fieldDisplay.value); +async function deleteBranchById(id: string) { + return await new Promise((resolve) => { + dialog({ + color: 'negative', + icon: 'mdi-alert', + title: t('deleteConfirmTitle'), + actionText: t('ok'), + persistent: true, + message: t('deleteConfirmMessage'), + action: async () => { + await customerStore.deleteBranchById(id); + await fetchList(); + flowStore.rotate(); + resolve(true); + customerBranchFormState.value.dialogModal = false; + }, + cancel: () => { + resolve(false); + }, + }); + }); +} + async function fetchList() { if (!customerId.value) return; @@ -449,20 +475,6 @@ watch([customerId, inputSearch, currentStatus], async () => { } " /> - - @@ -559,6 +571,11 @@ watch([customerId, inputSearch, currentStatus], async () => {