diff options
Diffstat (limited to 'client/components/home/_home.jsx')
-rw-r--r-- | client/components/home/_home.jsx | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/client/components/home/_home.jsx b/client/components/home/_home.jsx index 59389ad..02ebe38 100644 --- a/client/components/home/_home.jsx +++ b/client/components/home/_home.jsx @@ -1,3 +1,23 @@ +import { useContext } from 'react'; +import { SettingsContext } from '../../utils/settings_context'; + export const Home = () => { - return <div>I am the home page</div>; + 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> + ); }; |