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

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

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

<div class="create-conversation">
  <form {onsubmit}>
    <input type="text" placeholder="start a conversation" bind:value={name} {disabled} />
    <button type="submit">&#x2795;</button>
  </form>
</div>
