Fix event loading
This commit is contained in:
parent
8168cfa2c8
commit
f692616d2c
@ -50,17 +50,13 @@ export async function loader({ context }: { context: RequestContext }) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const calendarData = eventsData.results.map((e) => {
|
const calendarData = eventsData.results.map((e) => {
|
||||||
const dayDate = new Date(
|
|
||||||
e.year as number,
|
|
||||||
(e.month as number) - 1,
|
|
||||||
e.day as number,
|
|
||||||
);
|
|
||||||
return {
|
return {
|
||||||
id: e.id,
|
id: e.id,
|
||||||
title: (e.type as string).toUpperCase(),
|
title: (e.type as string).toUpperCase(),
|
||||||
allDay: true,
|
allDay: true,
|
||||||
start: dayDate,
|
// A Date object will not survive being passed to the client
|
||||||
end: dayDate,
|
start: `${e.year}-${e.month}-${e.day}T00:00:00.000Z`,
|
||||||
|
end: `${e.year}-${e.month}-${e.day}T00:00:00.000Z`,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -86,11 +82,13 @@ export default function () {
|
|||||||
return (
|
return (
|
||||||
<Container maxW="container.lg" h="600px">
|
<Container maxW="container.lg" h="600px">
|
||||||
<Calendar
|
<Calendar
|
||||||
|
endAccessor={(event) => new Date(event.end)}
|
||||||
events={data?.calendarData}
|
events={data?.calendarData}
|
||||||
localizer={dayjsLocalizer(dayjs)}
|
localizer={dayjsLocalizer(dayjs)}
|
||||||
onSelectSlot={(s) => {
|
onSelectSlot={(s) => {
|
||||||
setDate(s.slots.at(0) as Date);
|
setDate(s.slots.at(0) as Date);
|
||||||
}}
|
}}
|
||||||
|
startAccessor={(event) => new Date(event.start)}
|
||||||
style={{ height: 500 }}
|
style={{ height: 500 }}
|
||||||
/>
|
/>
|
||||||
<Accordion id="events-accordion" mt="16px">
|
<Accordion id="events-accordion" mt="16px">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user