<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 flex-nowrap">
    <input type="text" placeholder="create channel" bind:value={name} disabled={disabled} class="input flex-auto h-6" />
    <button type="submit" class="flex-none w-4 h-4">&#x2795;</button>
</form>

<style>
</style>
