diff --git a/app/ui/invitations/board.tsx b/app/ui/invitations/board.tsx index 9bb95e9..d34cbb8 100644 --- a/app/ui/invitations/board.tsx +++ b/app/ui/invitations/board.tsx @@ -18,6 +18,13 @@ export default function InvitationsBoard({ guests, invitations }: { ) ); + // Sort invitations to display those without guests at the top + const sortedInvitations = [...invitations].sort((a, b) => { + if (a.guests.length === 0 && b.guests.length > 0) return -1; + if (a.guests.length > 0 && b.guests.length === 0) return 1; + return 0; + }); + function handleCreateInvitation() { api.create(serializer, new Invitation(), () => { console.log("Invitation created successfully"); @@ -28,48 +35,54 @@ export default function InvitationsBoard({ guests, invitations }: {
{/* Left Column: Guests */}
-

{guests.length} guests without invitation

- +

{guests.length} guests without invitation

+
{/* Right Column: Invitations */}
-

- {invitations.length} invitations -

+

+ {invitations.length} invitations +

- - -
- {invitations.map((invitation, index) => ( -
-
    - {invitation.guests.map((guest) => ( -
  • {guest.name}
  • + Create New Invitation + + +
    + {sortedInvitations.map((invitation, index) => ( +
    + {invitation.guests.length === 0 ? ( +

    + (empty invitation) +

    + ) : ( +
      + {invitation.guests.map((guest) => ( +
    • {guest.name}
    • + ))} +
    + )} +
    ))} -
- ))} -
);