Skip to content

Commit

Permalink
messing with things i don't understand
Browse files Browse the repository at this point in the history
  • Loading branch information
Highfire1 committed Dec 4, 2024
1 parent a1068ba commit c821f6b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions frontend/src/app/events/EventsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import EventItem from './EventItem';

// Note that all of these can be null (except for id)
interface Event {
event_name: string;
event_date: string;
semester: string
event_start_date: string;
event_end_date: string;
location: string;
Expand All @@ -29,10 +31,10 @@ export default async function EventsPage() {
return dateToCheck <= currentDate && !isNaN(dateToCheck.getTime());
})
.reduce((acc: { [key: string]: Event[] }, event) => {
const dateToUse = event.event_end_date || event.event_start_date || event.event_date;
const year = new Date(dateToUse).getFullYear();
if (!acc[year]) acc[year] = [];
acc[year].push(event);
const s = event.semester
if (!acc[s]) acc[s] = [];

acc[s].push(event);
return acc;
}, {});

Expand Down Expand Up @@ -60,11 +62,11 @@ export default async function EventsPage() {
</div>

<h1 className="text-3xl pt-10 font-bold">Past Events:</h1>
{sortedYears.map(year => (
<div key={year} className=' items-center'>
<h2 className="text-2xl font-bold pt-4 pb-[5px]">{year}:</h2>
{sortedYears.map(term => (
<div key={term} className=' items-center'>
<h2 className="text-2xl font-bold pt-4 pb-[5px]">{term}:</h2>
<div className="past-events flex flex-wrap gap-5">
{pastEvents[year].map((event: Event) => (
{pastEvents[term].map((event: Event) => (
<EventItem key={event.id} past={true} event={event} />
))}
</div>
Expand Down

0 comments on commit c821f6b

Please sign in to comment.