Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix event loading
  • Loading branch information
regalijan committed Nov 5, 2024
1 parent 8168cfa commit f692616
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions app/routes/events-calendar.tsx
Expand Up @@ -50,17 +50,13 @@ export async function loader({ context }: { context: RequestContext }) {
});

const calendarData = eventsData.results.map((e) => {
const dayDate = new Date(
e.year as number,
(e.month as number) - 1,
e.day as number,
);
return {
id: e.id,
title: (e.type as string).toUpperCase(),
allDay: true,
start: dayDate,
end: dayDate,
// A Date object will not survive being passed to the client
start: `${e.year}-${e.month}-${e.day}T00:00:00.000Z`,
end: `${e.year}-${e.month}-${e.day}T00:00:00.000Z`,
};
});

Expand All @@ -86,11 +82,13 @@ export default function () {
return (
<Container maxW="container.lg" h="600px">
<Calendar
endAccessor={(event) => new Date(event.end)}
events={data?.calendarData}
localizer={dayjsLocalizer(dayjs)}
onSelectSlot={(s) => {
setDate(s.slots.at(0) as Date);
}}
startAccessor={(event) => new Date(event.start)}
style={{ height: 500 }}
/>
<Accordion id="events-accordion" mt="16px">
Expand Down

0 comments on commit f692616

Please sign in to comment.