refactor: refs #6739 new confirmation window
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jon Elias 2024-05-07 10:35:48 +02:00
parent 5ed2a82194
commit 7befca94bd
1 changed files with 18 additions and 23 deletions

View File

@ -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,18 +79,21 @@ 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
@ -96,16 +101,6 @@ const transferInvoice = async () => {
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 });
}
} catch (err) {
console.error('Error transfering invoice', err);
}