mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
feat: handle error message.
This commit is contained in:
@@ -9,6 +9,7 @@ import withAlertActions from 'containers/Alert/withAlertActions';
|
||||
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||
|
||||
import { useDeleteCreditNote } from 'hooks/query';
|
||||
import { handleDeleteErrors } from '../../Sales/CreditNotes/CreditNotesLanding/utils';
|
||||
import { compose } from 'utils';
|
||||
|
||||
/**
|
||||
@@ -48,7 +49,9 @@ function CreditNoteDeleteAlert({
|
||||
response: {
|
||||
data: { errors },
|
||||
},
|
||||
}) => {},
|
||||
}) => {
|
||||
handleDeleteErrors(errors);
|
||||
},
|
||||
)
|
||||
.finally(() => {
|
||||
closeAlert(name);
|
||||
|
||||
29
src/containers/Sales/CreditNotes/CreditNotesLanding/utils.js
Normal file
29
src/containers/Sales/CreditNotes/CreditNotesLanding/utils.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { Intent } from '@blueprintjs/core';
|
||||
import { AppToaster } from 'components';
|
||||
|
||||
export const handleDeleteErrors = (errors) => {
|
||||
if (
|
||||
errors.find((error) => error.type === 'CREDIT_NOTE_HAS_APPLIED_INVOICES')
|
||||
) {
|
||||
AppToaster.show({
|
||||
message: intl.get(
|
||||
'credit_note.error.you_couldn_t_delete_credit_note_that_has_associated_invoice',
|
||||
),
|
||||
intent: Intent.DANGER,
|
||||
});
|
||||
}
|
||||
if (
|
||||
errors.find(
|
||||
(error) => error.type === 'CREDIT_NOTE_HAS_REFUNDS_TRANSACTIONS',
|
||||
)
|
||||
) {
|
||||
AppToaster.show({
|
||||
message: intl.get(
|
||||
'credit_note.error.you_couldn_t_delete_credit_note_that_has_associated_refund',
|
||||
),
|
||||
intent: Intent.DANGER,
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -99,6 +99,18 @@ export const handleDeleteErrors = (errors) => {
|
||||
intent: Intent.DANGER,
|
||||
});
|
||||
}
|
||||
if (
|
||||
errors.find(
|
||||
(error) => error.type === 'SALE_INVOICE_HAS_APPLIED_TO_CREDIT_NOTES',
|
||||
)
|
||||
) {
|
||||
AppToaster.show({
|
||||
message: intl.get(
|
||||
'invoices.error.you_couldn_t_delete_sale_invoice_that_has_reconciled',
|
||||
),
|
||||
intent: Intent.DANGER,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export function ActionsMenu({
|
||||
|
||||
Reference in New Issue
Block a user