fix(server): Handle the delete error when the matched transaction

This commit is contained in:
Ahmed Bouhuolia
2024-06-29 10:30:03 +02:00
parent 978ce6c441
commit cb1f587637
9 changed files with 92 additions and 14 deletions

View File

@@ -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);
});

View 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.',
});
}
};