fix: transform message error with customers.

This commit is contained in:
elforjani3
2021-01-02 15:07:51 +02:00
parent 3c0dc6f27a
commit a1c228a8a4
2 changed files with 20 additions and 4 deletions

View File

@@ -146,6 +146,20 @@ function CustomersList({
setBulkDelete(false); setBulkDelete(false);
}, []); }, []);
const transformApiErrors = (errors) => {
if (
errors.find(
(error) => error.type === 'SOME.CUSTOMERS.HAVE.SALES_INVOICES',
)
) {
AppToaster.show({
message: formatMessage({
id: 'some_customers_have_sales_invoices',
}),
intent: Intent.DANGER,
});
}
};
// Handle confirm customers bulk delete. // Handle confirm customers bulk delete.
const handleConfirmBulkDelete = useCallback(() => { const handleConfirmBulkDelete = useCallback(() => {
requestDeleteBulkCustomers(bulkDelete) requestDeleteBulkCustomers(bulkDelete)
@@ -158,7 +172,8 @@ function CustomersList({
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
}) })
.catch((error) => { .catch((errors) => {
transformApiErrors(errors);
setBulkDelete(false); setBulkDelete(false);
}); });
}, [requestDeleteBulkCustomers, bulkDelete, formatMessage]); }, [requestDeleteBulkCustomers, bulkDelete, formatMessage]);

View File

@@ -938,5 +938,6 @@ export default {
no_results: 'No results.', no_results: 'No results.',
the_invoice_cannot_be_deleted: the_invoice_cannot_be_deleted:
'The invoice cannot be deleted cause has associated payment transactions', 'The invoice cannot be deleted cause has associated payment transactions',
category_name_exists:'Category name exists' category_name_exists: 'Category name exists',
}; some_customers_have_sales_invoices: 'Some customers have sales invoices',
};