import React from 'react'; import { Link as RouterLink } from 'react-router-dom'; // material-ui import { Button, Checkbox, FormControlLabel, FormHelperText, Grid, Link, InputAdornment, InputLabel, OutlinedInput, Stack, Typography } from '@mui/material'; // third party import * as Yup from 'yup'; import { Formik } from 'formik'; // project import import useAuth from 'hooks/useAuth'; import useScriptRef from 'hooks/useScriptRef'; import IconButton from 'components/@extended/IconButton'; import AnimateButton from 'components/@extended/AnimateButton'; // assets import { EyeOutlined, EyeInvisibleOutlined } from '@ant-design/icons'; // ============================|| JWT - LOGIN ||============================ // const AuthLogin = () => { const [checked, setChecked] = React.useState(false); const { login } = useAuth(); const scriptedRef = useScriptRef(); const [showPassword, setShowPassword] = React.useState(false); const handleClickShowPassword = () => { setShowPassword(!showPassword); }; const handleMouseDownPassword = (event) => { event.preventDefault(); }; return ( <> { try { await login(values.email, values.password); if (scriptedRef.current) { setStatus({ success: true }); setSubmitting(false); } } catch (err) { console.error(err); if (scriptedRef.current) { setStatus({ success: false }); setErrors({ submit: err.message }); setSubmitting(false); } } }} > {({ errors, handleBlur, handleChange, handleSubmit, isSubmitting, touched, values }) => (
Email Address {touched.email && errors.email && ( {errors.email} )} Password {showPassword ? : } } placeholder="Enter password" /> {touched.password && errors.password && ( {errors.password} )} setChecked(event.target.checked)} name="checked" color="primary" size="small" /> } label={Keep me sign in} /> Forgot Password? {errors.submit && ( {errors.submit} )}
)}
); }; export default AuthLogin;