import React, { useState } from "react"; import { withRouter } from "react-router-dom"; import { useDispatch, useSelector } from "react-redux"; import { Button, Form, FormGroup, Container } from "reactstrap"; import { SignUpLink } from "../SignUp"; import InputField from "../../components/InputField"; import { PasswordForgetLink } from "../PasswordForget"; import { signInAsync, selectError, createAuthUserWithGoogleAsync, } from "../../store/sessionSlice"; const useStyles = () => ({ root: { paddingTop: "1rem", paddingBottom: "1rem", }, button: { marginTop: "1rem", marginBottom: "1rem", }, }); /** * page's layout */ export default function SignInPage() { const styles = useStyles(); return (

Sign In

); } const SignInFormBase = (props) => { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const error = useSelector(selectError); const dispatch = useDispatch(); const handleSubmit = (e) => { e.preventDefault(); dispatch(signInAsync(email, password, props)); }; const loginWithGoogle = (e) => { e.preventDefault(); dispatch(createAuthUserWithGoogleAsync(props)); }; const isInvalid = email === "" || password === ""; const styles = useStyles(); return (
{error &&

{error.message}

}
); }; /** * Sign In form final component. withRouter allows redirections. */ export const SignInForm = withRouter(SignInFormBase);