Skip to content

Commit

Permalink
Filter events by upcoming date
Browse files Browse the repository at this point in the history
  • Loading branch information
andyren12 committed Sep 16, 2023
1 parent 6657928 commit e0f3506
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions pages/eventsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,18 @@ export default function Events({ events }: Props): JSX.Element {
//replace committee below
const committee = vars.committee.toLowerCase();

const filteredEvents = indexedEvents.filter(
(event) =>
event.committee === committee,
);
//get today's unix timestamp
const now = new Date();
now.setHours(0, 0, 0, 0);
const todayUnixTime = Math.floor(now.getTime() / 1000);

//filter by committee and if event is upcoming
const filteredEvents = indexedEvents.filter((event) => {
return (
event.committee === committee &&
parseInt(event.start) / 1000 >= todayUnixTime
);
});

if (committee === 'board') {
filteredEvents.shift();
Expand Down

0 comments on commit e0f3506

Please sign in to comment.