From 0885eef073608007d152d1c4ef5edf254f89fcf6 Mon Sep 17 00:00:00 2001 From: evgeniywas Date: Sun, 11 Jun 2023 11:36:42 +0100 Subject: [PATCH] RC-2: update signin and signup pages according to the design --- src/app/main/authPages/sign-in/SignInPage.js | 240 +++++------------- src/app/main/authPages/sign-up/SignUpPage.js | 246 +++++++------------ 2 files changed, 153 insertions(+), 333 deletions(-) diff --git a/src/app/main/authPages/sign-in/SignInPage.js b/src/app/main/authPages/sign-in/SignInPage.js index 09eb949..b46fe8b 100644 --- a/src/app/main/authPages/sign-in/SignInPage.js +++ b/src/app/main/authPages/sign-in/SignInPage.js @@ -1,32 +1,18 @@ import { yupResolver } from '@hookform/resolvers/yup'; -import { Controller, useForm } from 'react-hook-form'; +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 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 _ from '@lodash'; -import FuseSvgIcon from '@fuse/core/FuseSvgIcon'; -import AvatarGroup from '@mui/material/AvatarGroup'; -import Avatar from '@mui/material/Avatar'; -import Box from '@mui/material/Box'; -import Paper from '@mui/material/Paper'; -import { useEffect } from 'react'; -import jwtService from '../../../auth/services/jwtService'; - -/** - * Form Validation Schema - */ -const schema = yup.object().shape({ - email: yup.string().email('You must enter a valid email').required('You must enter a email'), - password: yup - .string() - .required('Please enter your password.') - .min(4, 'Password is too short - must be at least 4 chars.'), -}); +import AdditionalSignWays from '../shared-components/AdditionalSignWays'; +import LeftSideCanvas from '../shared-components/LeftSideCanvas'; const defaultValues = { email: '', @@ -34,8 +20,13 @@ const defaultValues = { remember: true, }; -function SignInPage() { - const { control, formState, handleSubmit, setError, setValue } = useForm({ +function SignInPage({ t }) { + const schema = yup.object().shape({ + email: yup.string().email(t('email_error')).required(t('email_error')), + password: yup.string().required(t('password_error')).min(8, t('password_error')), + }); + + const { control, formState, handleSubmit, reset } = useForm({ mode: 'onChange', defaultValues, resolver: yupResolver(schema), @@ -43,47 +34,33 @@ function SignInPage() { const { isValid, dirtyFields, errors } = formState; - useEffect(() => { - setValue('email', 'admin@fusetheme.com', { shouldDirty: true, shouldValidate: true }); - setValue('password', 'admin', { shouldDirty: true, shouldValidate: true }); - }, [setValue]); - - function onSubmit({ email, password }) { - jwtService - .signInWithEmailAndPassword(email, password) - .then((user) => { - // No need to do anything, user data will be set at app/auth/AuthContext - }) - .catch((_errors) => { - _errors.forEach((error) => { - setError(error.type, { - type: 'manual', - message: error.message, - }); - }); - }); + function onSubmit() { + reset(defaultValues); } return ( -
- -
- logo +
+ - + theme.palette.background?.authPaper }} + > +
+ Sign in -
- Don't have an account? - - Sign up +
+ {t('have_account')} + + {t('sign_up')}
( theme.palette.background.paper, + }, + }} /> )} /> @@ -111,14 +93,19 @@ function SignInPage() { render={({ field }) => ( theme.palette.background.paper, + }, + }} /> )} /> @@ -130,138 +117,43 @@ function SignInPage() { render={({ field }) => ( } + label={t('remember')} + control={ + theme.palette.border.light }} + /> + } /> )} /> - - Forgot password? + + {t('forgot_password')}
- - -
-
- - Or continue with - -
-
- -
- - -
+ +
- - - - - - - - - - - - - - - - - -
-
-
Welcome to
-
our community
-
-
- Fuse helps developers to build organized and well coded dashboards full of beautiful and - rich modules. Join us and start building your application today. -
-
- - - - - - - -
- More than 17k people joined us, it's your turn -
-
-
-
); } -export default SignInPage; +export default withTranslation('signInPage')(SignInPage); diff --git a/src/app/main/authPages/sign-up/SignUpPage.js b/src/app/main/authPages/sign-up/SignUpPage.js index 9985f73..02fe2d6 100644 --- a/src/app/main/authPages/sign-up/SignUpPage.js +++ b/src/app/main/authPages/sign-up/SignUpPage.js @@ -1,109 +1,94 @@ import { yupResolver } from '@hookform/resolvers/yup'; -import { Controller, useForm } from 'react-hook-form'; +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 _ from '@lodash'; -import AvatarGroup from '@mui/material/AvatarGroup'; -import Avatar from '@mui/material/Avatar'; -import Box from '@mui/material/Box'; -import Paper from '@mui/material/Paper'; -import FormHelperText from '@mui/material/FormHelperText'; -import jwtService from '../../../auth/services/jwtService'; - -/** - * Form Validation Schema - */ -const schema = yup.object().shape({ - displayName: yup.string().required('You must enter display name'), - email: yup.string().email('You must enter a valid email').required('You must enter a email'), - password: yup - .string() - .required('Please enter your password.') - .min(8, 'Password is too short - should be 8 chars minimum.'), - passwordConfirm: yup.string().oneOf([yup.ref('password'), null], 'Passwords must match'), - acceptTermsConditions: yup.boolean().oneOf([true], 'The terms and conditions must be accepted.'), -}); +import AdditionalSignWays from '../shared-components/AdditionalSignWays'; +import LeftSideCanvas from '../shared-components/LeftSideCanvas'; const defaultValues = { - displayName: '', + name: '', email: '', password: '', passwordConfirm: '', acceptTermsConditions: false, }; -function SignUpPage() { +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, setError } = formState; + const { isValid, dirtyFields, errors } = formState; - function onSubmit({ displayName, password, email }) { - jwtService - .createUser({ - displayName, - password, - email, - }) - .then((user) => { - // No need to do anything, registered user data will be set at app/auth/AuthContext - }) - .catch((_errors) => { - _errors.forEach((error) => { - setError(error.type, { - type: 'manual', - message: error.message, - }); - }); - }); + function onSubmit() { + reset(defaultValues); } return ( -
- -
- logo +
+ - - Sign up + theme.palette.background?.authPaper }} + > +
+ + {t('sign_up')} -
- Already have an account? - - Sign in +
+ {t('have_account')} + + {t('sign_in')}
( theme.palette.background.paper, + }, + }} /> )} /> @@ -114,14 +99,19 @@ function SignUpPage() { render={({ field }) => ( theme.palette.background.paper, + }, + }} /> )} /> @@ -132,14 +122,19 @@ function SignUpPage() { render={({ field }) => ( theme.palette.background.paper, + }, + }} /> )} /> @@ -150,14 +145,19 @@ function SignUpPage() { render={({ field }) => ( theme.palette.background.paper, + }, + }} /> )} /> @@ -166,110 +166,38 @@ function SignUpPage() { name="acceptTermsConditions" control={control} render={({ field }) => ( - + } + label={t('accept_terms')} + control={ + theme.palette.border.light }} /> + } /> {errors?.acceptTermsConditions?.message} )} /> - +
+ +
+ +
- - - - - - - - - - - - - - - - - -
-
-
Welcome to
-
our community
-
-
- Fuse helps developers to build organized and well coded dashboards full of beautiful and - rich modules. Join us and start building your application today. -
-
- - - - - - - -
- More than 17k people joined us, it's your turn -
-
-
-
); } -export default SignUpPage; +export default withTranslation('signUpPage')(SignUpPage);