<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 {onsubmit}>
  <button class="btn bg-primary-500" type="submit"> Create Invitation </button>
</form>

<ul class="mt-4">
  {#each invites as invite}
    <li class="my-1"><Invite id={invite.id} /></li>
  {/each}
</ul>
