feat(webapp): sign-up restrictions

This commit is contained in:
a.bouhuolia
2023-05-07 23:54:42 +02:00
parent ad3c9ebfe9
commit dd26bdc482
9 changed files with 148 additions and 35 deletions

View File

@@ -94,3 +94,29 @@ export const transformRegisterErrorsToForm = (errors) => {
}
return formErrors;
};
export const transformRegisterToastMessages = (errors) => {
const toastErrors = [];
if (errors.some((e) => e.type === 'SIGNUP_NOT_ALLOWED_EMAIL_DOMAIN')) {
toastErrors.push({
message:
'The sign-up is restricted, the given email domain is not allowed to sign-up.',
intent: Intent.DANGER,
});
} else if (
errors.some((e) => e.type === 'SIGNUP_NOT_ALLOWED_EMAIL_ADDRESS')
) {
toastErrors.push({
message:
'The sign-up is restricted, the given email address is not allowed to sign-up.',
intent: Intent.DANGER,
});
} else if (errors.find((e) => e.type === 'SIGNUP_RESTRICTED')) {
toastErrors.push({
message: 'Sign-up is disabled, and no new accounts can be created.',
intent: Intent.DANGER,
});
}
return toastErrors;
};