<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>

<ul>
  {#each invites as invite}
    <li><Invite id={invite.id} /></li>
  {/each}
</ul>
<form onsubmit={onSubmit}>
  <button class="btn variant-filled" type="submit"> Create Invitation </button>
</form>
