summaryrefslogtreecommitdiff
path: root/ui/lib/components/CreateChannelForm.svelte
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2025-02-24 11:41:24 -0500
committerOwen Jacobson <owen@grimoire.ca>2025-02-24 11:41:24 -0500
commit099471c574f6dceeb45f8bb5dae1699a734cb084 (patch)
tree945f44c9a90bf51de20c61a5a8c5ed82c2c05009 /ui/lib/components/CreateChannelForm.svelte
parent36cadfe00cacc6a6523f9862d3f7a08a9d0ce611 (diff)
parentfc0f1654a56d2247728a766f43e72ff169704888 (diff)
Merge branch 'prop/global-state-at-top-level'
Diffstat (limited to 'ui/lib/components/CreateChannelForm.svelte')
-rw-r--r--ui/lib/components/CreateChannelForm.svelte15
1 files changed, 8 insertions, 7 deletions
diff --git a/ui/lib/components/CreateChannelForm.svelte b/ui/lib/components/CreateChannelForm.svelte
index 85c85bb..471c2b7 100644
--- a/ui/lib/components/CreateChannelForm.svelte
+++ b/ui/lib/components/CreateChannelForm.svelte
@@ -1,21 +1,22 @@
<script>
- import { createChannel } from '$lib/apiServer';
+ let { createChannel = async (name) => {} } = $props();
let name = $state('');
let disabled = $state(false);
- async function handleSubmit(event) {
+ async function onsubmit(event) {
event.preventDefault();
disabled = true;
- const response = await createChannel(name);
- if (200 <= response.status && response.status < 300) {
- name = '';
+ try {
+ await createChannel(name);
+ event.target.reset();
+ } finally {
+ disabled = false;
}
- disabled = false;
}
</script>
-<form onsubmit={handleSubmit}>
+<form {onsubmit}>
<input type="text" placeholder="create channel" bind:value={name} {disabled} />
<button type="submit">&#x2795;</button>
</form>