Skip to content

Commit

Permalink
Merge pull request #46 from uclaacm/kevin
Browse files Browse the repository at this point in the history
fix: removed duplicate events from events page
  • Loading branch information
Kevin-D23 authored Jan 17, 2025
2 parents d82251e + a70a20d commit 48ce9d8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pages/eventsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<MainLayout>
<div className={styles.main}>
Expand All @@ -59,7 +69,7 @@ export default function Events({ events }: Props): JSX.Element {
<h4 className={styles.message}>Stay tuned for more events!</h4>
</div>
)}
{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 48ce9d8

Please sign in to comment.