From 4401dce2b5545ce8117818812d8e3c8919f5f7fd Mon Sep 17 00:00:00 2001
From: Owen Jacobson <owen@grimoire.ca>
Date: Thu, 10 Oct 2024 21:05:48 -0400
Subject: Remove redundancy in `hi-ui` directory name.

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

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

diff --git a/ui/src/lib/components/LogIn.svelte b/ui/src/lib/components/LogIn.svelte
new file mode 100644
index 0000000..2836e6d
--- /dev/null
+++ b/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

