"use client" // ** 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 Typography from '@mui/material/Typography' 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 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 LoginIllustration = styled('img')(({ theme }) => ({ zIndex: 2, maxHeight: 680, marginTop: theme.spacing(12), marginBottom: theme.spacing(12), [theme.breakpoints.down(1540)]: { maxHeight: 550 }, [theme.breakpoints.down('lg')]: { maxHeight: 500 } })) const RightWrapper = styled(Box)(({ theme }) => ({ width: '100%', [theme.breakpoints.up('md')]: { maxWidth: 450 }, [theme.breakpoints.up('lg')]: { maxWidth: 600 }, [theme.breakpoints.up('xl')]: { maxWidth: 750 } })) const LinkStyled = styled(Link)(({ theme }) => ({ fontSize: '0.875rem', textDecoration: 'none', color: theme.palette.primary.main })) 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@vuexy.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', }) 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 ? ( theme.spacing(8, 0, 8, 8) }} > ) : null} {`Welcome to ${themeConfig.templateName}! 👋🏻`} Please sign-in to your account and start the adventure Admin: admin@vuexy.com / Pass: admin Client: client@vuexy.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(6)} !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