Skip to content

Commit

Permalink
fix: removed duplicate events from events page
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin-D23 committed Jan 17, 2025
1 parent 250ab5e commit 8fd2f3c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pages/eventsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,18 @@ export default function Events({ events }: Props): JSX.Element {
(event) => event.committee === committee,
);

const uniqueEvents = Array.from(
// filters out identical events, ignoring "id" field
new Map(
filteredEvents.map((event) => [
JSON.stringify({ ...event, id: undefined }),
event,
]),
).values(),
);

if (committee === 'board') {
filteredEvents.shift();
uniqueEvents.shift();
}

return (
Expand All @@ -70,7 +80,7 @@ export default function Events({ events }: Props): JSX.Element {
</p> */}
<div>
<h2 className={styles.subtitle}>Upcoming Events</h2>
{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');
Expand Down

0 comments on commit 8fd2f3c

Please sign in to comment.