Skip to content

Commit

Permalink
show only upcoming events
Browse files Browse the repository at this point in the history
  • Loading branch information
ArshMalik02 committed Sep 23, 2023
1 parent cb4683c commit 892ccd8
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions pages/eventsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,6 @@ interface Event {
banner: string;
}

// interface EventClass {
// className?: string;
// }

// const getEventClassByEvent = (event: Event): EventClass => {
// if (!event) {
// return {};
// }
// let modifierStr = '';
// if (event.committee) {
// modifierStr = `rbc-override-${event.committee}`;
// }
// return ({
// className: `rbc-override-event ${modifierStr}`,
// });
// };

interface Props {
events: Event[];
committee: string;
Expand All @@ -51,9 +34,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 892ccd8

Please sign in to comment.