<script>
  import { createInvite } from '$lib/apiServer';
  import Invite from '$lib/components/Invite.svelte';

  let invites = $state([]);

  async function onsubmit(event) {
    event.preventDefault();
    let response = await createInvite();
    if (response.status == 200) {
      invites.push(response.data);
    }
  }
</script>

<form class="form" {onsubmit}>
  <button type="submit">create invitation</button>
</form>

<ul class="invite-list">
  {#each invites as invite}
    <li><Invite id={invite.id} /></li>
  {/each}
</ul>
