diff options
| author | Kit La Touche <kit@transneptune.net> | 2024-10-09 15:32:52 -0400 |
|---|---|---|
| committer | Kit La Touche <kit@transneptune.net> | 2024-10-09 15:32:52 -0400 |
| commit | bd53a51af835478d23bef4772ce7e50553dc3fdf (patch) | |
| tree | 3f190a47b9f704c412d0ff684b959abf003b8e5b /hi-ui/src/lib/components/LogOut.svelte | |
| parent | dd62b823e01934a0f841256fdb17b551091896bf (diff) | |
Move a lot of things around
Diffstat (limited to 'hi-ui/src/lib/components/LogOut.svelte')
| -rw-r--r-- | hi-ui/src/lib/components/LogOut.svelte | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/hi-ui/src/lib/components/LogOut.svelte b/hi-ui/src/lib/components/LogOut.svelte new file mode 100644 index 0000000..01bef1b --- /dev/null +++ b/hi-ui/src/lib/components/LogOut.svelte @@ -0,0 +1,22 @@ +<script> + import { logOut} from '$lib/apiServer'; + import { currentUser } from '$lib/store'; + + async function handleLogout(event) { + const response = await logOut(); + if (200 <= response.status && response.status < 300) { + currentUser.update(() => null); + } + } +</script> + +<form on:submit|preventDefault={handleLogout}> + @{$currentUser.username} + <button + class="border-slate-500 border-solid border-2 font-bold p-1 rounded" + type="submit" + >log out</button> +</form> + +<style> +</style> |
