Skip to content
Snippets Groups Projects
Verified Commit ba7da0a6 authored by Defendi Alberto's avatar Defendi Alberto
Browse files

Implement history push

parent 3a9bb39f
No related branches found
No related tags found
1 merge request!30Role
......@@ -4,6 +4,8 @@ import { SubmitHandler, useForm } from 'react-hook-form';
import { createStyles, makeStyles, Theme } from '@material-ui/core/styles';
import { Button } from '@material-ui/core';
import { InputField } from 'components/AuthUser/SignInForm/InputField/InputField';
import { useHistory } from 'react-router-dom';
import { AuthRoutes } from 'components/api/routes';
const useStyles = makeStyles((theme: Theme) =>
createStyles({
......@@ -22,8 +24,9 @@ const useStyles = makeStyles((theme: Theme) =>
}),
);
// TODO: real time form validation
export const SignInForm: FC = () => {
const history = useHistory();
interface FormData {
email: string;
password: string;
......@@ -39,19 +42,22 @@ export const SignInForm: FC = () => {
});
const onSubmit: SubmitHandler<FormData> = (values: FormData) => {
axios.post(
'/api/web/login',
{
username: values.email,
password: values.password,
},
{
headers: {
'Content-Type': 'application/json',
axios
.post(
'/api/web/login',
{
username: values.email,
password: values.password,
},
},
);
{
headers: {
'Content-Type': 'application/json',
},
},
)
.then(() => history.replace(AuthRoutes.dashboard));
};
const classes = useStyles();
return (
<>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment