"use client"; import { useRSVPData } from "components/PageSWRDataProvider"; import { ButtonTertiary } from "components/Buttons"; import { Popover } from "components/Popover"; export function Attendees(props: { entityID: string; className?: string }) { let { data } = useRSVPData(); let attendees = data?.rsvps?.filter((rsvp) => rsvp.entity === props.entityID) || []; let going = attendees.filter((rsvp) => rsvp.status === "GOING"); let maybe = attendees.filter((rsvp) => rsvp.status === "MAYBE"); let notGoing = attendees.filter((rsvp) => rsvp.status === "NOT_GOING"); return ( No RSVPs yet ) : ( {going.length > 0 && `${going.reduce((acc, g) => acc + 1 + g.plus_ones, 0)} Going`} {maybe.length > 0 && `${going.length > 0 ? ", " : ""}${maybe.reduce((acc, m) => acc + 1 + m.plus_ones, 0)} Maybe`} ) } > {going.length === 0 && maybe.length === 0 && notGoing.length === 0 && (
No RSVPs yet
)}
); } function AttendeeStatusList(props: { rsvps: Array<{ name: string; phone_number?: string; plus_ones: number; status: string; }>; title: string; }) { if (props.rsvps.length === 0) return null; return (
{props.title} ({props.rsvps.length})
{props.rsvps.map((rsvp) => (
{rsvp.name} {rsvp.plus_ones > 0 ? `+${rsvp.plus_ones}` : ""}
))}
); }