summaryrefslogtreecommitdiff
path: root/hi-ui/src/lib/CreateChannelForm.svelte
diff options
context:
space:
mode:
authorKit La Touche <kit@transneptune.net>2024-09-19 23:26:39 -0400
committerKit La Touche <kit@transneptune.net>2024-09-27 16:10:36 -0400
commit1d8b828d1bbe0e0daa64f6fc2689799c7169afa0 (patch)
treec51149769901f733e6ec159597d185a0cefeea15 /hi-ui/src/lib/CreateChannelForm.svelte
parent80af9cfb858dd18bc1cf26ce213aecd52bd8fc7b (diff)
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!
Diffstat (limited to 'hi-ui/src/lib/CreateChannelForm.svelte')
-rw-r--r--hi-ui/src/lib/CreateChannelForm.svelte27
1 files changed, 27 insertions, 0 deletions
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>