mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 14:50:32 +00:00
fix : handle errors message in sale invoice
This commit is contained in:
@@ -78,17 +78,36 @@ function InvoiceList({
|
|||||||
setDeleteInvoice(false);
|
setDeleteInvoice(false);
|
||||||
}, [setDeleteInvoice]);
|
}, [setDeleteInvoice]);
|
||||||
|
|
||||||
// handleConfirm delete invoice
|
const handleDeleteErrors = (errors) => {
|
||||||
const handleConfirmInvoiceDelete = useCallback(() => {
|
if (
|
||||||
requestDeleteInvoice(deleteInvoice.id).then(() => {
|
errors.find(
|
||||||
|
(error) => error.type === 'INVOICE_HAS_ASSOCIATED_PAYMENT_ENTRIES',
|
||||||
|
)
|
||||||
|
) {
|
||||||
AppToaster.show({
|
AppToaster.show({
|
||||||
message: formatMessage({
|
message: formatMessage({
|
||||||
id: 'the_invocie_has_been_successfully_deleted',
|
id: 'the_invoice_cannot_be_deleted',
|
||||||
}),
|
}),
|
||||||
intent: Intent.SUCCESS,
|
intent: Intent.DANGER,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// handleConfirm delete invoice
|
||||||
|
const handleConfirmInvoiceDelete = useCallback(() => {
|
||||||
|
requestDeleteInvoice(deleteInvoice.id)
|
||||||
|
.then(() => {
|
||||||
|
AppToaster.show({
|
||||||
|
message: formatMessage({
|
||||||
|
id: 'the_invocie_has_been_successfully_deleted',
|
||||||
|
}),
|
||||||
|
intent: Intent.SUCCESS,
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((errors) => {
|
||||||
|
handleDeleteErrors(errors);
|
||||||
|
setDeleteInvoice(false);
|
||||||
});
|
});
|
||||||
setDeleteInvoice(false);
|
|
||||||
});
|
|
||||||
}, [deleteInvoice, requestDeleteInvoice, formatMessage]);
|
}, [deleteInvoice, requestDeleteInvoice, formatMessage]);
|
||||||
|
|
||||||
// Handle cancel/confirm invoice deliver.
|
// Handle cancel/confirm invoice deliver.
|
||||||
|
|||||||
Reference in New Issue
Block a user