summaryrefslogtreecommitdiff
path: root/ui/lib/components/CreateConversationForm.svelte
blob: d6056d3d896b29404de70a4acb2baccabf1caa7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<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>