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 { ref, reactive, onMounted } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { useQuasar } from 'quasar';
import VnConfirm from 'components/ui/VnConfirm.vue';
import VnRow from 'components/ui/VnRow.vue'; import VnRow from 'components/ui/VnRow.vue';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import VnSelect from 'components/common/VnSelect.vue'; import VnSelect from 'components/common/VnSelect.vue';
@ -18,6 +19,7 @@ const $props = defineProps({
}, },
}); });
const quasar = useQuasar();
const { t } = useI18n(); const { t } = useI18n();
const router = useRouter(); const router = useRouter();
const { notify } = useNotify(); const { notify } = useNotify();
@ -77,35 +79,28 @@ const handleScroll = async () => {
await fetchClients(); await fetchClients();
} }
}; };
const transferInvoice = async () => { const transferInvoice = async () => {
try { try {
const clientDetails = await axios.get( const clientDetails = await axios.get(
`Clients/${transferInvoiceParams.newClientFk}` `Clients/${transferInvoiceParams.newClientFk}`
); );
const hasToInvoiceByAddress = clientDetails.data.hasToInvoiceByAddress;
if (checked.value && hasToInvoiceByAddress) { if (checked.value && clientDetails.data.hasToInvoiceByAddress)
const confirmed = confirm(t('confirmationInfo')); quasar.dialog({
component: VnConfirm,
componentProps: {
title: t('Bill destination client'),
message: t('confirmationInfo'),
},
});
if (confirmed) { const { data } = await axios.post(
const { data } = await axios.post( 'InvoiceOuts/transferInvoice',
'InvoiceOuts/transferInvoice', transferInvoiceParams
transferInvoiceParams );
); notify(t('Transferred invoice'), 'positive');
notify(t('Transferred invoice'), 'positive'); closeForm();
closeForm(); router.push('InvoiceOutSummary', { id: data.id });
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) { } catch (err) {
console.error('Error transfering invoice', err); console.error('Error transfering invoice', err);
} }