Properly fix it this time
This commit is contained in:
parent
cbe2913f2d
commit
fa288b604e
@ -14,6 +14,7 @@ import {
|
|||||||
} from "@chakra-ui/react";
|
} from "@chakra-ui/react";
|
||||||
import { useLoaderData } from "@remix-run/react";
|
import { useLoaderData } from "@remix-run/react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import utc from "dayjs/plugin/utc.js";
|
||||||
|
|
||||||
export const links: LinksFunction = () => {
|
export const links: LinksFunction = () => {
|
||||||
return [
|
return [
|
||||||
@ -55,8 +56,8 @@ export async function loader({ context }: { context: RequestContext }) {
|
|||||||
title: (e.type as string).toUpperCase(),
|
title: (e.type as string).toUpperCase(),
|
||||||
allDay: true,
|
allDay: true,
|
||||||
// A Date object will not survive being passed to the client
|
// A Date object will not survive being passed to the client
|
||||||
start: `${e.year}-${e.month}-${e.day}T00:00:00.000Z`,
|
start: `${e.year}-${(e.month as number).toString().padStart(2, "0")}-${(e.day as number).toString().padStart(2, "0")}T00:00:00.000Z`,
|
||||||
end: `${e.year}-${e.month}-${e.day}T00:00:00.000Z`,
|
end: `${e.year}-${(e.month as number).toString().padStart(2, "0")}-${(e.day as number).toString().padStart(2, "0")}T00:00:00.000Z`,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -79,22 +80,31 @@ export default function () {
|
|||||||
) as { [k: string]: any }[];
|
) as { [k: string]: any }[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dayjs.extend(utc);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container maxW="container.lg" h="600px">
|
<Container maxW="container.lg" h="600px">
|
||||||
<Calendar
|
<Calendar
|
||||||
events={data?.calendarData.map((event) => {
|
endAccessor={(event) => new Date(event.end)}
|
||||||
// @ts-expect-error
|
events={data.calendarData}
|
||||||
event.end = new Date(event.end);
|
|
||||||
// @ts-expect-error
|
|
||||||
event.start = new Date(event.start);
|
|
||||||
|
|
||||||
return event;
|
|
||||||
})}
|
|
||||||
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) => {
|
||||||
|
const date = new Date(event.start);
|
||||||
|
date.setUTCDate(date.getUTCDate() + 1);
|
||||||
|
|
||||||
|
return date;
|
||||||
|
}}
|
||||||
style={{ height: 500 }}
|
style={{ height: 500 }}
|
||||||
|
views={{
|
||||||
|
month: true,
|
||||||
|
week: false,
|
||||||
|
work_week: false,
|
||||||
|
day: false,
|
||||||
|
agenda: false,
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<Accordion id="events-accordion" mt="16px">
|
<Accordion id="events-accordion" mt="16px">
|
||||||
<AccordionItem>
|
<AccordionItem>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user