diff options
| author | Raphael Kabo <raphaelkabo@hey.com> | 2024-02-05 19:26:34 +0000 | 
|---|---|---|
| committer | Raphael Kabo <raphaelkabo@hey.com> | 2024-02-05 21:47:07 +0000 | 
| commit | 2b47f4f8141820835c778ea748f8ae7f47ef261d (patch) | |
| tree | 579dceb4a0b456d985708d2a12042de03a3549d5 /src | |
| parent | 2402f88e0e907877a295350c57d2dd88edff6cd0 (diff) | |
Handle hidden attendees in frontend
Diffstat (limited to 'src')
| -rw-r--r-- | src/routes/frontend.ts | 22 | 
1 files changed, 21 insertions, 1 deletions
diff --git a/src/routes/frontend.ts b/src/routes/frontend.ts index cc97ab8..23418df 100644 --- a/src/routes/frontend.ts +++ b/src/routes/frontend.ts @@ -159,6 +159,24 @@ router.get("/:eventID", async (req: Request, res: Response) => {                  }                  return acc;              }, 0) || 0; +        const visibleAttendees = event.attendees?.filter( +            (attendee) => attendee.visibility === "public", +        ); +        const hiddenAttendees = event.attendees?.filter( +            (attendee) => attendee.visibility === "private", +        ); +        const numberOfHiddenAttendees = event.attendees?.reduce( +            (acc, attendee) => { +                if ( +                    attendee.status === "attending" && +                    attendee.visibility === "private" +                ) { +                    return acc + (attendee.number || 1); +                } +                return acc; +            }, +            0, +        );          if (event.maxAttendees) {              spotsRemaining = event.maxAttendees - numberOfAttendees;              if (spotsRemaining <= 0) { @@ -189,8 +207,10 @@ router.get("/:eventID", async (req: Request, res: Response) => {                  title: event.name,                  escapedName: escapedName,                  eventData: event, -                eventAttendees: eventAttendees, +                visibleAttendees, +                hiddenAttendees,                  numberOfAttendees, +                numberOfHiddenAttendees,                  spotsRemaining: spotsRemaining,                  noMoreSpots: noMoreSpots,                  eventStartISO: eventStartISO,  | 
