mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
fix: transform message error with customers.
This commit is contained in:
@@ -59,7 +59,7 @@ function CustomersList({
|
||||
['resource-views', 'customers'],
|
||||
(key, resourceName) => requestFetchResourceViews(resourceName),
|
||||
);
|
||||
|
||||
|
||||
const fetchCustomers = useQuery(
|
||||
['customers-table', customersTableQuery],
|
||||
(key, query) => requestFetchCustomers({ ...query }),
|
||||
@@ -146,6 +146,20 @@ function CustomersList({
|
||||
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.
|
||||
const handleConfirmBulkDelete = useCallback(() => {
|
||||
requestDeleteBulkCustomers(bulkDelete)
|
||||
@@ -158,7 +172,8 @@ function CustomersList({
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch((errors) => {
|
||||
transformApiErrors(errors);
|
||||
setBulkDelete(false);
|
||||
});
|
||||
}, [requestDeleteBulkCustomers, bulkDelete, formatMessage]);
|
||||
|
||||
@@ -938,5 +938,6 @@ export default {
|
||||
no_results: 'No results.',
|
||||
the_invoice_cannot_be_deleted:
|
||||
'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',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user