prevent lectures from dropping on each other

This commit is contained in:
2024-11-02 13:17:36 -06:00
parent b5dc579411
commit 14003d52c9
9 changed files with 212 additions and 67 deletions

View File

@@ -1,20 +1,14 @@
"use client";
import {
dateToMarkdownString,
getDateFromStringOrThrow,
getDateOnlyMarkdownString,
} from "@/models/local/timeUtils";
import { useDraggingContext } from "../../context/draggingContext";
import { useCourseContext } from "../../context/courseContext";
import Link from "next/link";
import { useLocalCourseSettingsQuery } from "@/hooks/localCourse/localCoursesHooks";
import { getDayOfWeek } from "@/models/local/localCourse";
import { getLectureUrl } from "@/services/urlUtils";
import { ItemInDay } from "./ItemInDay";
import { useTodaysItems } from "./useTodaysItems";
import Modal from "@/components/Modal";
import NewItemForm from "../../modules/NewItemForm";
import { useLecturesByWeekQuery } from "@/hooks/localCourse/lectureHooks";
import { DayTitle } from "./DayTitle";
export default function Day({ day, month }: { day: string; month: number }) {
const dayAsDate = getDateFromStringOrThrow(
@@ -130,33 +124,3 @@ export default function Day({ day, month }: { day: string; month: number }) {
</div>
);
}
function DayTitle({ day, dayAsDate }: { day: string; dayAsDate: Date }) {
const { courseName } = useCourseContext();
const { data: weeks } = useLecturesByWeekQuery();
const todaysLecture = weeks
.flatMap((w) => w.lectures)
.find((l) => l.date == getDateOnlyMarkdownString(dayAsDate));
return (
<div className="flex justify-between">
<Link
className="ms-1 me-1 truncate text-nowrap transition-all hover:font-bold hover:text-slate-300"
href={getLectureUrl(courseName, day)}
>
{dayAsDate.getDate()} {todaysLecture?.name}
</Link>
<Modal
buttonText="+"
buttonClass="unstyled hover:font-bold hover:scale-125 px-1 mb-auto mt-0 pt-0"
>
{({ closeModal }) => (
<div>
<NewItemForm creationDate={day} onCreate={closeModal} />
<br />
<button onClick={closeModal}>close</button>
</div>
)}
</Modal>
</div>
);
}