Skip to content

Commit

Permalink
feat(events): update event dates to use new API fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert27 committed Dec 2, 2024
1 parent fd5a739 commit 0def0de
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions rogue-thi-app/lib/backend/neuland-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ class NeulandAPIClient {
en
}
location
begin
end
startDateTime
endDateTime
}
}
`.replace(/\s+/g, ' ')
Expand Down
8 changes: 5 additions & 3 deletions rogue-thi-app/pages/api/cl-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ export default async function handler(req, res) {
.timezone('Europe/Berlin')
.ttl(60 * 60 * 24)
for (const event of plan.clEvents) {
const start = new Date(Number(event.begin))
const start = new Date(event.startDateTime)
let end = event.endDateTime ? new Date(event.endDateTime) : undefined

// discard the end if it is before the start
const end =
event.end > event.begin ? new Date(Number(event.end)) : undefined
if (end && end < start) {
end = undefined
}

cal.createEvent({
id: event.id,
Expand Down
8 changes: 5 additions & 3 deletions rogue-thi-app/pages/events.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,12 @@ export default function Events({ initialCampusEvents, sportsEvents }) {
return initialCampusEvents
.map((x) => ({
...x,
begin: x.begin ? new Date(Number(x.begin)) : null,
end: x.end ? new Date(Number(x.end)) : null,
begin: x.startDateTime ? new Date(x.startDateTime) : null,
end: x.endDateTime ? new Date(x.endDateTime) : null,
}))
.filter((x) => x.end === null || x.end > new Date())
.filter(
(x) => x.endDateTime === null || new Date(x.endDateTime) > new Date()
)
}, [initialCampusEvents])

const weekdaySports = useMemo(
Expand Down

0 comments on commit 0def0de

Please sign in to comment.