<script lang="ts">
  import DataTable from '@components/admin/table/DataTable.svelte';
  import { confirmPopupState } from '@components/popup/ConfirmPopup.ts';
  import {
    deleteDirectInvitation,
    type DirectInvitation,
    directInvitations
  } from '@app/admin/directInvitations/directInvitations.ts';

  // callback
  function onDirectInvitationDelete(directInvitation: DirectInvitation) {
    $confirmPopupState = {
      title: 'Direkte Einladung löschen?',
      message: 'Soll die direkte Einladung wirklich gelöscht werden?',
      onConfirm: () => deleteDirectInvitation(directInvitation)
    };
  }
</script>

<DataTable
  data={directInvitations}
  count={true}
  keys={[
    { key: 'url', label: 'Link', width: 50 },
    { key: 'user.username', label: 'Registrierter Nutzer', width: 40, sortable: true }
  ]}
  onDelete={onDirectInvitationDelete}
/>
