Remove events accordion
This commit is contained in:
parent
0cfc972dae
commit
fc654c2399
@ -5,12 +5,6 @@ import { Calendar, dayjsLocalizer } from "react-big-calendar";
|
||||
import dayjs from "dayjs";
|
||||
import { type LinksFunction } from "@remix-run/cloudflare";
|
||||
import {
|
||||
Accordion,
|
||||
AccordionButton,
|
||||
AccordionIcon,
|
||||
AccordionItem,
|
||||
AccordionPanel,
|
||||
Box,
|
||||
Button,
|
||||
Container,
|
||||
Heading,
|
||||
@ -90,10 +84,6 @@ export async function loader({ context }: { context: RequestContext }) {
|
||||
export default function () {
|
||||
const data = useLoaderData<typeof loader>();
|
||||
const [eventData, setEventData] = useState({} as { [k: string]: any });
|
||||
const [todayFOTD, setTodayFOTD] = useState("None");
|
||||
const [todayGameNight, setTodayGameNight] = useState("None");
|
||||
const [todayQOTD, setTodayQOTD] = useState("None");
|
||||
const [todayROTW, setTodayROTW] = useState("None");
|
||||
const { isOpen, onClose, onOpen } = useDisclosure();
|
||||
|
||||
dayjs.extend(utc);
|
||||
@ -147,82 +137,12 @@ export default function () {
|
||||
);
|
||||
onOpen();
|
||||
}}
|
||||
onSelectSlot={(s) => {
|
||||
const day = s.start.getUTCDate();
|
||||
const month = s.start.getUTCMonth() + 1;
|
||||
|
||||
for (const [type, setter] of Object.entries({
|
||||
fotd: setTodayFOTD,
|
||||
gamenight: setTodayGameNight,
|
||||
qotd: setTodayQOTD,
|
||||
rotw: setTodayROTW,
|
||||
})) {
|
||||
const event = data.eventList.find(
|
||||
(ev) => ev.type === type && ev.day === day && ev.month === month,
|
||||
);
|
||||
|
||||
if (!event) continue;
|
||||
|
||||
setter(
|
||||
event.type === "rotw"
|
||||
? `${event.details}\n\nAnswer: ${event.answer}`
|
||||
: (event.details as string),
|
||||
);
|
||||
}
|
||||
}}
|
||||
popup
|
||||
startAccessor={(event) => new Date(event.start)}
|
||||
style={{ height: 500 }}
|
||||
toolbar={false}
|
||||
views={["month"]}
|
||||
/>
|
||||
<Accordion id="events-accordion" mt="16px">
|
||||
<AccordionItem>
|
||||
<h2>
|
||||
<AccordionButton>
|
||||
<Box as="span" flex="1" textAlign="left">
|
||||
Fact of the Day
|
||||
</Box>
|
||||
<AccordionIcon />
|
||||
</AccordionButton>
|
||||
</h2>
|
||||
<AccordionPanel pb={4}>
|
||||
{todayFOTD}
|
||||
<br />
|
||||
</AccordionPanel>
|
||||
</AccordionItem>
|
||||
<AccordionItem>
|
||||
<h2>
|
||||
<AccordionButton>
|
||||
<Box as="span" flex="1" textAlign="left">
|
||||
Gamenight
|
||||
</Box>
|
||||
<AccordionIcon />
|
||||
</AccordionButton>
|
||||
</h2>
|
||||
<AccordionPanel pb={4}>{todayGameNight}</AccordionPanel>
|
||||
</AccordionItem>
|
||||
<AccordionItem>
|
||||
<h2>
|
||||
<AccordionButton>
|
||||
<Box as="span" flex="1" textAlign="left">
|
||||
Riddle of the Week
|
||||
</Box>
|
||||
</AccordionButton>
|
||||
</h2>
|
||||
<AccordionPanel pb={4}>{todayROTW}</AccordionPanel>
|
||||
</AccordionItem>
|
||||
<AccordionItem>
|
||||
<h2>
|
||||
<AccordionButton>
|
||||
<Box as="span" flex="1" textAlign="left">
|
||||
Question of the Day
|
||||
</Box>
|
||||
</AccordionButton>
|
||||
</h2>
|
||||
<AccordionPanel pb={4}>{todayQOTD}</AccordionPanel>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user