<script>
  let { createChannel = async (name) => {} } = $props();

  let name = $state('');
  let disabled = $state(false);

  async function onsubmit(event) {
    event.preventDefault();
    disabled = true;
    try {
      await createChannel(name);
      event.target.reset();
    } finally {
      disabled = false;
    }
  }
</script>

<form {onsubmit}>
  <input type="text" placeholder="create channel" bind:value={name} {disabled} />
  <button type="submit">&#x2795;</button>
</form>
