RC-4: move authRoles to src/app/configs

This commit is contained in:
2023-06-22 19:56:33 +01:00
parent b11e5db2e7
commit cc6c57655e
14 changed files with 34 additions and 178 deletions

View File

@@ -1,7 +1,7 @@
import i18next from 'i18next';
import SignUpPage from './SignUpPage';
import authRoles from '../../../auth/authRoles';
import authRoles from '../../../configs/authRoles';
import en from './i18n/en';
i18next.addResourceBundle('en', 'signUpPage', en);

View File

@@ -11,6 +11,7 @@ import Typography from '@mui/material/Typography';
import { Controller, useForm } from 'react-hook-form';
import { withTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';
import { authService } from 'src/app/services';
import * as yup from 'yup';
import LeftSideCanvas from '../shared-components/LeftSideCanvas';
@@ -31,7 +32,7 @@ function SignUpPage({ t }) {
acceptTermsConditions: yup.boolean().oneOf([true], t('accept_terms_error')),
});
const { control, formState, handleSubmit, reset } = useForm({
const { control, formState, handleSubmit, setError } = useForm({
mode: 'onChange',
defaultValues,
resolver: yupResolver(schema),
@@ -39,8 +40,19 @@ function SignUpPage({ t }) {
const { isValid, dirtyFields, errors } = formState;
function onSubmit() {
reset(defaultValues);
function onSubmit({ name, password, email }) {
authService
.createUser({
displayName: name,
password,
email,
})
.catch((error) => {
setError('root', {
type: 'manual',
message: error.message,
});
});
}
return (