From a70a20df8bebfa1ed60d282486d24ea5fbaa312c Mon Sep 17 00:00:00 2001 From: Kevin-D23 <116064184+Kevin-D23@users.noreply.github.com> Date: Tue, 14 Jan 2025 00:11:02 -0800 Subject: [PATCH] fix: removed duplicate events from events page --- pages/eventsPage.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pages/eventsPage.tsx b/pages/eventsPage.tsx index 93f9fc5..a1bb61a 100644 --- a/pages/eventsPage.tsx +++ b/pages/eventsPage.tsx @@ -47,6 +47,16 @@ export default function Events({ events }: Props): JSX.Element { ); }); + const uniqueEvents = Array.from( + // filters out identical events, ignoring "id" field + new Map( + filteredEvents.map((event) => [ + JSON.stringify({ ...event, id: undefined }), + event, + ]), + ).values(), + ); + return (
@@ -59,7 +69,7 @@ export default function Events({ events }: Props): JSX.Element {

Stay tuned for more events!

)} - {filteredEvents.map((event, index) => { + {uniqueEvents.map((event, index) => { const start = format(new Date(event.start), 'h:mma'); const end = format(new Date(event.end), 'h:mma'); const startDate = format(new Date(event.start), 'E MMM d');