'use client'; import { AbstractApi } from "@/app/api/abstract-api"; import { Guest } from "@/app/lib/guest"; import { Invitation, InvitationSerializer } from "@/app/lib/invitation"; export default function InvitationsBoard({ guests, invitations }: { guests: Array, invitations: Array }) { const api = new AbstractApi(); const serializer = new InvitationSerializer(); // Filter out guests that are already in invitations const availableGuests = guests.filter( (guest) => !invitations.some((invitation) => invitation.guests.some((invitedGuest) => invitedGuest.id === guest.id) ) ); function handleCreateInvitation() { api.create(serializer, new Invitation(), () => { console.log("Invitation created successfully"); }); } return (
{/* Left Column: Guests */}

Guests

    {availableGuests.map((guest, index) => (
  • {guest.name}

  • ))}
{/* Right Column: Invitations */}

Invitations

{invitations.map((invitation, index) => (
    {invitation.guests.map((guest) => (
  • {guest.name}
  • ))}
))}
); }