Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: removed duplicate events from events page #46

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading