Skip to content

Commit

Permalink
Redirecting programmaticall
Browse files Browse the repository at this point in the history
  • Loading branch information
Wellington Mazoni committed Oct 18, 2023
1 parent 253cfad commit 9503a8e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion frontend/src/pages/Admin/Auth/Login/index.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -13,6 +13,7 @@ type FormData = {
const Login = () => {
const [hasError, setHasError] = useState(false);
const { register, handleSubmit, formState: {errors} } = useForm<FormData>();
const history = useHistory();
const onSubmit = (formData: FormData) => {
requestBackendLogin(formData)
.then((response) => {
Expand All @@ -21,6 +22,7 @@ const Login = () => {
console.log('TOKEN gerado: ' + token)
setHasError(false);
console.log('SUCESSO', response);
history.push('/admin');
})
.catch((error) => {
setHasError(true);
Expand Down

0 comments on commit 9503a8e

Please sign in to comment.