mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06:40:31 +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 withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||||
|
|
||||||
import { useDeleteCreditNote } from 'hooks/query';
|
import { useDeleteCreditNote } from 'hooks/query';
|
||||||
|
import { handleDeleteErrors } from '../../Sales/CreditNotes/CreditNotesLanding/utils';
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,7 +49,9 @@ function CreditNoteDeleteAlert({
|
|||||||
response: {
|
response: {
|
||||||
data: { errors },
|
data: { errors },
|
||||||
},
|
},
|
||||||
}) => {},
|
}) => {
|
||||||
|
handleDeleteErrors(errors);
|
||||||
|
},
|
||||||
)
|
)
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
closeAlert(name);
|
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,
|
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({
|
export function ActionsMenu({
|
||||||
|
|||||||
Reference in New Issue
Block a user