mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 23:58:31 -06:00
prevent lectures from dropping on each other
This commit is contained in:
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user