From bd53a51af835478d23bef4772ce7e50553dc3fdf Mon Sep 17 00:00:00 2001
From: Kit La Touche <kit@transneptune.net>
Date: Wed, 9 Oct 2024 15:32:52 -0400
Subject: Move a lot of things around

---
 hi-ui/src/lib/components/LogIn.svelte | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 hi-ui/src/lib/components/LogIn.svelte

(limited to 'hi-ui/src/lib/components/LogIn.svelte')

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>
-- 
cgit v1.2.3

