fix (Invite user): catch message error.

This commit is contained in:
elforjani3
2021-04-06 17:57:46 +02:00
parent 6f36f32f7c
commit 5a38ae246d
2 changed files with 10 additions and 1 deletions

View File

@@ -55,7 +55,13 @@ function InviteUserForm({
};
// Handle the response error.
const onError = (errors) => {
const onError = (error) => {
const {
response: {
data: { errors },
},
} = error;
const errorsTransformed = transformApiErrors(errors);
setErrors({ ...errorsTransformed });

View File

@@ -6,5 +6,8 @@ export const transformApiErrors = (errors) => {
if (errors.find((error) => error.type === 'EMAIL.ALREADY.INVITED')) {
fields.email = formatMessage({ id: 'email_is_already_used' });
}
if (errors.find((error) => error.type === 'EMAIL.ALREADY.EXISTS')) {
fields.email = formatMessage({ id: 'email_is_already_used' });
}
return fields;
};