summaryrefslogtreecommitdiff
path: root/hi-ui/src/lib/CreateChannelForm.svelte
blob: 265ab7ee982a2f795361801ed6a24fc0154ac262 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<script>
    import { createChannel } from '../apiServer';

    let name = '';
    let disabled = false;

    async function handleSubmit(event) {
        disabled = true;
        const response = await createChannel(name);
        if (200 <= response.status && response.status < 300) {
            name = '';
        }
        disabled = false;
    }
</script>

<form on:submit|preventDefault={handleSubmit} class="form form-row">
    <input type="text" placeholder="channel name" bind:value={name} disabled={disabled} class="flex-auto h-6" />
    <button type="submit" class="flex-none w-4 h-4">&#x2795;</button>
</form>

<style>
</style>