diff --git a/nextjs/src/app/course/[courseName]/calendar/CalendarMonth.tsx b/nextjs/src/app/course/[courseName]/calendar/CalendarMonth.tsx
index d045ef8..11e9454 100644
--- a/nextjs/src/app/course/[courseName]/calendar/CalendarMonth.tsx
+++ b/nextjs/src/app/course/[courseName]/calendar/CalendarMonth.tsx
@@ -1,8 +1,8 @@
"use client";
-import { useState } from "react";
import { CalendarMonthModel } from "./calendarMonthUtils";
import { DayOfWeek } from "@/models/local/localCourse";
import Day from "./day/Day";
+import { Expandable } from "@/components/Expandable";
export const CalendarMonth = ({ month }: { month: CalendarMonthModel }) => {
const weekInMilliseconds = 604_800_000;
@@ -10,33 +10,30 @@ export const CalendarMonth = ({ month }: { month: CalendarMonthModel }) => {
new Date(month.year, month.month, 1) <
new Date(Date.now() - weekInMilliseconds);
- const [isCollapsed, setIsCollapsed] = useState(isInPast);
-
const monthName = new Date(month.year, month.month - 1, 1).toLocaleString(
"default",
{ month: "long" }
);
- const toggleCollapse = () => setIsCollapsed(!isCollapsed);
const weekDaysList: DayOfWeek[] = Object.values(DayOfWeek);
return (
<>
-
(
+
+
setIsExpanded((e) => !e)}
+ role="button"
+ >
+ {monthName}
+
+
+ )}
>
{weekDaysList.map((day) => (
@@ -49,7 +46,7 @@ export const CalendarMonth = ({ month }: { month: CalendarMonthModel }) => {
{month.daysByWeek.map((week, weekIndex) => (
))}
-
+
>
);
};
diff --git a/nextjs/src/app/course/[courseName]/modules/ExpandableModule.tsx b/nextjs/src/app/course/[courseName]/modules/ExpandableModule.tsx
index 4fa636c..48a5f56 100644
--- a/nextjs/src/app/course/[courseName]/modules/ExpandableModule.tsx
+++ b/nextjs/src/app/course/[courseName]/modules/ExpandableModule.tsx
@@ -1,18 +1,14 @@
"use client";
import { useAssignmentsQueries } from "@/hooks/localCourse/assignmentHooks";
-import {
- usePagesQueries,
-} from "@/hooks/localCourse/pageHooks";
-import {
- useQuizzesQueries,
-} from "@/hooks/localCourse/quizHooks";
+import { usePagesQueries } from "@/hooks/localCourse/pageHooks";
+import { useQuizzesQueries } from "@/hooks/localCourse/quizHooks";
import { IModuleItem } from "@/models/local/IModuleItem";
import {
getDateFromString,
getDateFromStringOrThrow,
getDateOnlyMarkdownString,
} from "@/models/local/timeUtils";
-import { Fragment, useRef, useState } from "react";
+import { Fragment } from "react";
import Modal from "../../../../components/Modal";
import NewItemForm from "./NewItemForm";
import { ModuleCanvasStatus } from "./ModuleCanvasStatus";
@@ -23,6 +19,7 @@ import DropTargetStyling from "../../../../components/DropTargetStyling";
import Link from "next/link";
import { getModuleItemUrl } from "@/services/urlUtils";
import { useCourseContext } from "../context/courseContext";
+import { Expandable } from "../../../../components/Expandable";
export default function ExpandableModule({
moduleName,
@@ -35,7 +32,7 @@ export default function ExpandableModule({
const { data: quizzes } = useQuizzesQueries(moduleName);
const { data: pages } = usePagesQueries(moduleName);
- const [expanded, setExpanded] = useState(false);
+ // const [expanded, setExpanded] = useState(false);
const moduleItems: {
type: "assignment" | "quiz" | "page";
@@ -65,7 +62,7 @@ export default function ExpandableModule({
"item due date in expandable module"
).getTime()
);
- const expandRef = useRef
(null);
+ // const expandRef = useRef(null);
return (
-
setExpanded((e) => !e)}
- >
-
{moduleName}
-
-
-
-
-
-
-
-
-
- {({ closeModal }) => (
-
-
-
-
+
(
+ setIsExpanded((e) => !e)}
+ >
+
{moduleName}
+
+
+
+
+
- )}
-
-
- {moduleItems.map(({ type, item }) => (
-
- ))}
-
-
+
+ )}
+ >
+ <>
+
+ {({ closeModal }) => (
+
+
+
+
+
+ )}
+
+
+ {moduleItems.map(({ type, item }) => (
+
+ ))}
+
+ >
+
diff --git a/nextjs/src/components/Expandable.tsx b/nextjs/src/components/Expandable.tsx
new file mode 100644
index 0000000..583d2e5
--- /dev/null
+++ b/nextjs/src/components/Expandable.tsx
@@ -0,0 +1,36 @@
+"use client";
+import { ReactNode, Dispatch, SetStateAction, useState, useRef } from "react";
+
+export function Expandable({
+ children,
+ ExpandableElement,
+ defaultExpanded = false,
+}: {
+ children: ReactNode;
+ ExpandableElement: (props: {
+ setIsExpanded: Dispatch>;
+ isExpanded: boolean;
+ }) => ReactNode;
+ defaultExpanded?: boolean;
+}) {
+ const [isExpanded, setIsExpanded] = useState(defaultExpanded);
+ const expandRef = useRef(null);
+
+ return (
+ <>
+
+
+ {children}
+
+ >
+ );
+}