From 9503a8e83bd51ebacff7396c40381067493d9ac4 Mon Sep 17 00:00:00 2001 From: Wellington Mazoni Date: Wed, 18 Oct 2023 10:23:15 -0300 Subject: [PATCH] Redirecting programmaticall --- frontend/src/pages/Admin/Auth/Login/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/Admin/Auth/Login/index.tsx b/frontend/src/pages/Admin/Auth/Login/index.tsx index b40f8ec..dc0a998 100644 --- a/frontend/src/pages/Admin/Auth/Login/index.tsx +++ b/frontend/src/pages/Admin/Auth/Login/index.tsx @@ -1,4 +1,4 @@ -import { Link } from 'react-router-dom'; +import { Link, useHistory } from 'react-router-dom'; import ButtonIcon from 'components/ButtonIcon'; import { useForm } from 'react-hook-form'; import './styles.css'; @@ -13,6 +13,7 @@ type FormData = { const Login = () => { const [hasError, setHasError] = useState(false); const { register, handleSubmit, formState: {errors} } = useForm(); + const history = useHistory(); const onSubmit = (formData: FormData) => { requestBackendLogin(formData) .then((response) => { @@ -21,6 +22,7 @@ const Login = () => { console.log('TOKEN gerado: ' + token) setHasError(false); console.log('SUCESSO', response); + history.push('/admin'); }) .catch((error) => { setHasError(true);