// ** React Imports import { useState, ReactNode, MouseEvent } from 'react' // ** Next Imports import Link from 'next/link' // ** MUI Components import Alert from '@mui/material/Alert' import Button from '@mui/material/Button' import Divider from '@mui/material/Divider' import Checkbox from '@mui/material/Checkbox' import TextField from '@mui/material/TextField' import InputLabel from '@mui/material/InputLabel' import IconButton from '@mui/material/IconButton' import Box, { BoxProps } from '@mui/material/Box' import FormControl from '@mui/material/FormControl' import useMediaQuery from '@mui/material/useMediaQuery' import OutlinedInput from '@mui/material/OutlinedInput' import { styled, useTheme } from '@mui/material/styles' import FormHelperText from '@mui/material/FormHelperText' import InputAdornment from '@mui/material/InputAdornment' import Typography, { TypographyProps } from '@mui/material/Typography' import MuiFormControlLabel, { FormControlLabelProps } from '@mui/material/FormControlLabel' // ** Icon Imports import Icon from 'src/@core/components/icon' // ** Third Party Imports import * as yup from 'yup' import { useForm, Controller } from 'react-hook-form' import { yupResolver } from '@hookform/resolvers/yup' // ** Hooks import { useAuth } from 'src/hooks/useAuth' import useBgColor from 'src/@core/hooks/useBgColor' import { useSettings } from 'src/@core/hooks/useSettings' // ** Configs import themeConfig from 'src/configs/themeConfig' // ** Layout Import import BlankLayout from 'src/@core/layouts/BlankLayout' // ** Demo Imports import FooterIllustrationsV2 from 'src/views/pages/auth/FooterIllustrationsV2' // ** Styled Components const LoginIllustrationWrapper = styled(Box)(({ theme }) => ({ padding: theme.spacing(20), paddingRight: '0 !important', [theme.breakpoints.down('lg')]: { padding: theme.spacing(10) } })) const LoginIllustration = styled('img')(({ theme }) => ({ maxWidth: '48rem', [theme.breakpoints.down('xl')]: { maxWidth: '38rem' }, [theme.breakpoints.down('lg')]: { maxWidth: '30rem' } })) const RightWrapper = styled(Box)(({ theme }) => ({ width: '100%', [theme.breakpoints.up('md')]: { maxWidth: 400 }, [theme.breakpoints.up('lg')]: { maxWidth: 450 } })) const BoxWrapper = styled(Box)(({ theme }) => ({ width: '100%', [theme.breakpoints.down('md')]: { maxWidth: 400 } })) const TypographyStyled = styled(Typography)(({ theme }) => ({ fontWeight: 600, letterSpacing: '0.18px', marginBottom: theme.spacing(1.5), [theme.breakpoints.down('md')]: { marginTop: theme.spacing(8) } })) const FormControlLabel = styled(MuiFormControlLabel)(({ theme }) => ({ '& .MuiFormControlLabel-label': { fontSize: '0.875rem', color: theme.palette.text.secondary } })) const schema = yup.object().shape({ email: yup.string().email().required(), password: yup.string().min(5).required() }) const defaultValues = { password: 'admin', email: 'admin@materialize.com' } interface FormData { email: string password: string } const LoginPage = () => { const [rememberMe, setRememberMe] = useState(true) const [showPassword, setShowPassword] = useState(false) // ** Hooks const auth = useAuth() const theme = useTheme() const bgColors = useBgColor() const { settings } = useSettings() const hidden = useMediaQuery(theme.breakpoints.down('md')) // ** Vars const { skin } = settings const { control, setError, handleSubmit, formState: { errors } } = useForm({ defaultValues, mode: 'onBlur', resolver: yupResolver(schema) }) const onSubmit = (data: FormData) => { const { email, password } = data auth.login({ email, password, rememberMe }, () => { setError('email', { type: 'manual', message: 'Email or Password is invalid' }) }) } const imageSource = skin === 'bordered' ? 'auth-v2-login-illustration-bordered' : 'auth-v2-login-illustration' return ( {!hidden ? ( ) : null} {themeConfig.templateName} {`Welcome to ${themeConfig.templateName}! 👋🏻`} Please sign-in to your account and start the adventure Admin: admin@materialize.com / Pass: admin Client: client@materialize.com / Pass: client
( )} /> {errors.email && {errors.email.message}} Password ( e.preventDefault()} onClick={() => setShowPassword(!showPassword)} > } /> )} /> {errors.password && ( {errors.password.message} )} setRememberMe(e.target.checked)} />} /> Forgot Password? New on our platform? Create an account `${theme.spacing(5)} !important`, mb: theme => `${theme.spacing(7.5)} !important` }} > or ) => e.preventDefault()} > ) => e.preventDefault()} > ) => e.preventDefault()} sx={{ color: theme => (theme.palette.mode === 'light' ? '#272727' : 'grey.300') }} > ) => e.preventDefault()} >
) } LoginPage.getLayout = (page: ReactNode) => {page} LoginPage.guestGuard = true export default LoginPage