From 1d8b828d1bbe0e0daa64f6fc2689799c7169afa0 Mon Sep 17 00:00:00 2001
From: Kit La Touche <kit@transneptune.net>
Date: Thu, 19 Sep 2024 23:26:39 -0400
Subject: Add basic browser client

Using Svelte.

No tests, no linting, yet.

This is just starting to get familiar with things.

You'll still have to run the dev server and the dev client builder each
in their own terminals.

Enjoy!
---
 hi-ui/src/lib/CreateChannelForm.svelte | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 hi-ui/src/lib/CreateChannelForm.svelte

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

diff --git a/hi-ui/src/lib/CreateChannelForm.svelte b/hi-ui/src/lib/CreateChannelForm.svelte
new file mode 100644
index 0000000..584fa61
--- /dev/null
+++ b/hi-ui/src/lib/CreateChannelForm.svelte
@@ -0,0 +1,27 @@
+<script>
+    import { createChannel } from '../apiServer';
+
+    import { channelsList } from '../store';
+
+    let name = '';
+    let disabled = false;
+
+    async function handleSubmit(event) {
+        event.preventDefault();
+        disabled = true;
+        const response = await createChannel(name);
+        if (200 <= response.status && response.status < 300) {
+            channelsList.update((value) => [...value, response.data]);
+            name = '';
+        }
+        disabled = false;
+    }
+</script>
+
+<form on:submit={handleSubmit}>
+    <input type="text" placeholder="channel name" bind:value={name} disabled={disabled} />
+    <button type="submit">create</button>
+</form>
+
+<style>
+</style>
-- 
cgit v1.2.3

