From 7befca94bda44686025779d90232b53152ee7e19 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 7 May 2024 10:35:48 +0200 Subject: [PATCH] refactor: refs #6739 new confirmation window --- src/components/TransferInvoiceForm.vue | 41 +++++++++++--------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/src/components/TransferInvoiceForm.vue b/src/components/TransferInvoiceForm.vue index 637ebda64..b3c40b696 100644 --- a/src/components/TransferInvoiceForm.vue +++ b/src/components/TransferInvoiceForm.vue @@ -2,7 +2,8 @@ import { ref, reactive, onMounted } from 'vue'; import { useI18n } from 'vue-i18n'; import { useRouter } from 'vue-router'; - +import { useQuasar } from 'quasar'; +import VnConfirm from 'components/ui/VnConfirm.vue'; import VnRow from 'components/ui/VnRow.vue'; import FetchData from 'components/FetchData.vue'; import VnSelect from 'components/common/VnSelect.vue'; @@ -18,6 +19,7 @@ const $props = defineProps({ }, }); +const quasar = useQuasar(); const { t } = useI18n(); const router = useRouter(); const { notify } = useNotify(); @@ -77,35 +79,28 @@ const handleScroll = async () => { await fetchClients(); } }; - const transferInvoice = async () => { try { const clientDetails = await axios.get( `Clients/${transferInvoiceParams.newClientFk}` ); - const hasToInvoiceByAddress = clientDetails.data.hasToInvoiceByAddress; - if (checked.value && hasToInvoiceByAddress) { - const confirmed = confirm(t('confirmationInfo')); + if (checked.value && clientDetails.data.hasToInvoiceByAddress) + quasar.dialog({ + component: VnConfirm, + componentProps: { + title: t('Bill destination client'), + message: t('confirmationInfo'), + }, + }); - if (confirmed) { - const { data } = await axios.post( - 'InvoiceOuts/transferInvoice', - transferInvoiceParams - ); - notify(t('Transferred invoice'), 'positive'); - closeForm(); - router.push('InvoiceOutSummary', { id: data.id }); - } - } else { - const { data } = await axios.post( - 'InvoiceOuts/transferInvoice', - transferInvoiceParams - ); - notify(t('Transferred invoice'), 'positive'); - closeForm(); - router.push('InvoiceOutSummary', { id: data.id }); - } + const { data } = await axios.post( + 'InvoiceOuts/transferInvoice', + transferInvoiceParams + ); + notify(t('Transferred invoice'), 'positive'); + closeForm(); + router.push('InvoiceOutSummary', { id: data.id }); } catch (err) { console.error('Error transfering invoice', err); }