summaryrefslogtreecommitdiff
path: root/hi-ui/src/lib/components/LogIn.svelte
diff options
context:
space:
mode:
authorKit La Touche <kit@transneptune.net>2024-10-09 15:32:52 -0400
committerKit La Touche <kit@transneptune.net>2024-10-09 15:32:52 -0400
commitbd53a51af835478d23bef4772ce7e50553dc3fdf (patch)
tree3f190a47b9f704c412d0ff684b959abf003b8e5b /hi-ui/src/lib/components/LogIn.svelte
parentdd62b823e01934a0f841256fdb17b551091896bf (diff)
Move a lot of things around
Diffstat (limited to 'hi-ui/src/lib/components/LogIn.svelte')
-rw-r--r--hi-ui/src/lib/components/LogIn.svelte35
1 files changed, 35 insertions, 0 deletions
diff --git a/hi-ui/src/lib/components/LogIn.svelte b/hi-ui/src/lib/components/LogIn.svelte
new file mode 100644
index 0000000..2836e6d
--- /dev/null
+++ b/hi-ui/src/lib/components/LogIn.svelte
@@ -0,0 +1,35 @@
+<script>
+ import { logIn } from '$lib/apiServer';
+ import { currentUser } from '$lib/store';
+
+ let disabled = false;
+ let username = '';
+ let password = '';
+
+ async function handleLogin(event) {
+ disabled = true;
+ const response = await logIn(username, password);
+ if (200 <= response.status && response.status < 300) {
+ currentUser.update(() => ({ username }));
+ username = '';
+ password = '';
+ }
+ disabled = false;
+ }
+</script>
+
+<div class="card m-4 p-4">
+ <form on:submit|preventDefault={handleLogin}>
+ <label class="label" for="username">
+ username
+ <input class="input" name="username" type="text" placeholder="username" bind:value={username} disabled={disabled}>
+ </label>
+ <label class="label" for="password">
+ password
+ <input class="input" name="password" type="password" placeholder="password" bind:value={password} disabled={disabled}>
+ </label>
+ <button class="btn variant-filled" type="submit">
+ sign in or up
+ </button>
+ </form>
+</div>