-
Defendi Alberto authoredDefendi Alberto authored
ProfilePage.tsx 720 B
import React, { FC, useContext } from 'react';
import Button from '@material-ui/core/Button';
import axios from 'axios';
import { NonAuthRoutes } from 'api/routes';
import { useHistory } from 'react-router-dom';
import { AuthContext } from 'components/Auth/AuthContext';
export const ProfilePage: FC = () => {
const history = useHistory();
const { setIsAuth } = useContext(AuthContext);
const logout = (): void => {
axios.get('/api/web/login/logout').then(() => {
setIsAuth(false);
history.replace(NonAuthRoutes.home);
});
};
return (
<div data-testid="ProfilePage">
<Button variant="outlined" color="default" onClick={logout}>
Logout
</Button>
</div>
);
};