<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}>
    <input type="text" placeholder="channel name" bind:value={name} disabled={disabled} />
    <button type="submit">create</button>
</form>

<style>
</style>
