mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 14:50:32 +00:00
fix(server): Handle the delete error when the matched transaction
This commit is contained in:
@@ -12,6 +12,7 @@ import { useDeletePaymentMade } from '@/hooks/query';
|
||||
|
||||
import { compose } from '@/utils';
|
||||
import { DRAWERS } from '@/constants/drawers';
|
||||
import { handleDeleteErrors } from './_utils';
|
||||
|
||||
/**
|
||||
* Payment made delete alert.
|
||||
@@ -47,6 +48,15 @@ function PaymentMadeDeleteAlert({
|
||||
});
|
||||
closeDrawer(DRAWERS.PAYMENT_MADE_DETAILS);
|
||||
})
|
||||
.catch(
|
||||
({
|
||||
response: {
|
||||
data: { errors },
|
||||
},
|
||||
}) => {
|
||||
handleDeleteErrors(errors);
|
||||
},
|
||||
)
|
||||
.finally(() => {
|
||||
closeAlert(name);
|
||||
});
|
||||
|
||||
11
packages/webapp/src/containers/Alerts/PaymentMades/_utils.ts
Normal file
11
packages/webapp/src/containers/Alerts/PaymentMades/_utils.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { AppToaster } from '@/components';
|
||||
import { Intent } from '@blueprintjs/core';
|
||||
|
||||
export const handleDeleteErrors = (errors: any) => {
|
||||
if (errors.find((e: any) => e.type === 'CANNOT_DELETE_TRANSACTION_MATCHED')) {
|
||||
AppToaster.show({
|
||||
intent: Intent.DANGER,
|
||||
message: 'Cannot delete a transaction matched with a bank transaction.',
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user