import React, { useState } from "react"; import { useDispatch, useSelector } from "react-redux"; import { actionLogin } from "../../redux/actions/creators/auth"; import Avatar from "@mui/material/Avatar"; import Button from "@mui/material/Button"; import CssBaseline from "@mui/material/CssBaseline"; import TextField from "@mui/material/TextField"; import { Link, Navigate } from "react-router-dom"; import Grid from "@mui/material/Grid"; import Box from "@mui/material/Box"; import LockOutlinedIcon from "@mui/icons-material/LockOutlined"; import Typography from "@mui/material/Typography"; import Container from "@mui/material/Container"; import { createTheme, ThemeProvider } from "@mui/material/styles"; import MuiAlert from "@mui/material/Alert"; import Snackbar from "@mui/material/Snackbar"; import { createSelector } from "reselect"; import { useForm } from "react-hook-form"; const theme = createTheme({ palette: { mode: "dark", }, }); const Alert = React.forwardRef(function Alert(props, ref) { return ; }); const authState = createSelector( (state) => state.auth, (auth) => auth ); const Login = () => { const dispatch = useDispatch(); const { status, authToken } = useSelector(authState); const { register, handleSubmit, reset } = useForm(); const [error, setError] = useState(false); const submitHandler = ({ email, password }) => { dispatch(actionLogin(email, password)); reset(); }; const handleClose = (event, reason) => { if (reason === "clickaway") return; setError(false); }; if (authToken) return ; return ( Such user is not found OR the data is not correct! Login {"Don't have an account? Sign Up"} ); }; export default Login;