2021-11-22 16:21:53 -05:00
|
|
|
import { useContext } from 'react';
|
|
|
|
import { SettingsContext } from '../../utils/settings_context';
|
|
|
|
|
2021-11-20 20:18:58 -05:00
|
|
|
export const Home = () => {
|
2021-11-22 16:21:53 -05:00
|
|
|
const [, dispatch] = useContext(SettingsContext);
|
|
|
|
const logout = async () => {
|
|
|
|
const res = await fetch('/sessions', {
|
|
|
|
method: 'DELETE',
|
|
|
|
});
|
|
|
|
if (res.status === 200) {
|
|
|
|
dispatch({ type: 'update', payload: { jwt: undefined } });
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<h1>Welcome</h1>
|
|
|
|
<button type="button" onClick={logout}>
|
|
|
|
Logout
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
);
|
2021-11-20 20:18:58 -05:00
|
|
|
};
|