import { yupResolver } from '@hookform/resolvers/yup'; import _ from '@lodash'; import Button from '@mui/material/Button'; import Checkbox from '@mui/material/Checkbox'; import FormControl from '@mui/material/FormControl'; import FormControlLabel from '@mui/material/FormControlLabel'; import FormHelperText from '@mui/material/FormHelperText'; import Paper from '@mui/material/Paper'; import TextField from '@mui/material/TextField'; 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 * as yup from 'yup'; import LeftSideCanvas from '../shared-components/LeftSideCanvas'; const defaultValues = { name: '', email: '', password: '', passwordConfirm: '', acceptTermsConditions: false, }; function SignUpPage({ t }) { const schema = yup.object().shape({ name: yup.string().required(t('name_error')), email: yup.string().email(t('email_error')).required(t('email_error')), password: yup.string().required(t('password_error')).min(8, t('password_error')), passwordConfirm: yup.string().oneOf([yup.ref('password'), null], t('password_confirm_error')), acceptTermsConditions: yup.boolean().oneOf([true], t('accept_terms_error')), }); const { control, formState, handleSubmit, reset } = useForm({ mode: 'onChange', defaultValues, resolver: yupResolver(schema), }); const { isValid, dirtyFields, errors } = formState; function onSubmit() { reset(defaultValues); } return (
theme.palette.background?.authPaper }} >
{t('sign_up')}
{t('have_account')} {t('sign_in')}
( theme.palette.background.paper, }, }} /> )} /> ( theme.palette.background.paper, }, }} /> )} /> ( theme.palette.background.paper, }, }} /> )} /> ( theme.palette.background.paper, }, }} /> )} /> ( theme.palette.border.light }} /> } /> {errors?.acceptTermsConditions?.message} )} />
); } export default withTranslation('signUpPage')(SignUpPage);