mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
fix : handle errors message with item categories.
This commit is contained in:
@@ -80,8 +80,16 @@ function ItemCategoryFormDialogContent({
|
||||
[],
|
||||
);
|
||||
|
||||
const transformErrors = (errors, { setErrors }) => {
|
||||
if (errors.find((error) => error.type === 'CATEGORY_NAME_EXISTS')) {
|
||||
setErrors({
|
||||
name: formatMessage({ id: 'category_name_exists' }),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Handles the form submit.
|
||||
const handleFormSubmit = (values, { setSubmitting }) => {
|
||||
const handleFormSubmit = (values, { setSubmitting, setErrors }) => {
|
||||
setSubmitting(true);
|
||||
const form = { ...values };
|
||||
const afterSubmit = () => {
|
||||
@@ -100,7 +108,9 @@ function ItemCategoryFormDialogContent({
|
||||
});
|
||||
afterSubmit(response);
|
||||
};
|
||||
const onError = ({ response }) => {
|
||||
|
||||
const onError = (errors) => {
|
||||
transformErrors(errors, { setErrors });
|
||||
setSubmitting(false);
|
||||
};
|
||||
if (isNewMode) {
|
||||
|
||||
Reference in New Issue
Block a user