mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
better representation of un-named lectures on calendar view
This commit is contained in:
@@ -15,6 +15,8 @@ export function DayTitle({ day, dayAsDate }: { day: string; dayAsDate: Date }) {
|
|||||||
const todaysLecture = getLectureForDay(weeks, dayAsDate);
|
const todaysLecture = getLectureForDay(weeks, dayAsDate);
|
||||||
const modal = useModal();
|
const modal = useModal();
|
||||||
|
|
||||||
|
const lectureName = todaysLecture && (todaysLecture.name || "lecture");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<Link
|
<Link
|
||||||
@@ -36,7 +38,7 @@ export function DayTitle({ day, dayAsDate }: { day: string; dayAsDate: Date }) {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{dayAsDate.getDate()} {todaysLecture?.name}
|
{dayAsDate.getDate()} {lectureName}
|
||||||
</Link>
|
</Link>
|
||||||
<Modal
|
<Modal
|
||||||
modalControl={modal}
|
modalControl={modal}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import { useUpdateAssignmentMutation } from "@/hooks/localCourse/assignmentHooks";
|
import { useUpdateAssignmentMutation } from "@/hooks/localCourse/assignmentHooks";
|
||||||
import { useLecturesByWeekQuery, useLectureUpdateMutation } from "@/hooks/localCourse/lectureHooks";
|
import {
|
||||||
|
useLecturesByWeekQuery,
|
||||||
|
useLectureUpdateMutation,
|
||||||
|
} from "@/hooks/localCourse/lectureHooks";
|
||||||
import { useLocalCourseSettingsQuery } from "@/hooks/localCourse/localCoursesHooks";
|
import { useLocalCourseSettingsQuery } from "@/hooks/localCourse/localCoursesHooks";
|
||||||
import { useUpdatePageMutation } from "@/hooks/localCourse/pageHooks";
|
import { useUpdatePageMutation } from "@/hooks/localCourse/pageHooks";
|
||||||
import { useUpdateQuizMutation } from "@/hooks/localCourse/quizHooks";
|
import { useUpdateQuizMutation } from "@/hooks/localCourse/quizHooks";
|
||||||
@@ -9,20 +12,27 @@ import { Lecture } from "@/models/local/lecture";
|
|||||||
import { getLectureForDay } from "@/models/local/lectureUtils";
|
import { getLectureForDay } from "@/models/local/lectureUtils";
|
||||||
import { LocalCoursePage } from "@/models/local/page/localCoursePage";
|
import { LocalCoursePage } from "@/models/local/page/localCoursePage";
|
||||||
import { LocalQuiz } from "@/models/local/quiz/localQuiz";
|
import { LocalQuiz } from "@/models/local/quiz/localQuiz";
|
||||||
import { getDateFromStringOrThrow, getDateOnlyMarkdownString, dateToMarkdownString } from "@/models/local/timeUtils";
|
import {
|
||||||
|
getDateFromStringOrThrow,
|
||||||
|
getDateOnlyMarkdownString,
|
||||||
|
dateToMarkdownString,
|
||||||
|
} from "@/models/local/timeUtils";
|
||||||
import { Dispatch, SetStateAction, useCallback, DragEvent } from "react";
|
import { Dispatch, SetStateAction, useCallback, DragEvent } from "react";
|
||||||
import { DraggableItem } from "./draggingContext";
|
import { DraggableItem } from "./draggingContext";
|
||||||
import { getNewLockDate } from "./getNewLockDate";
|
import { getNewLockDate } from "./getNewLockDate";
|
||||||
|
|
||||||
|
|
||||||
export function useItemDropOnDay({
|
export function useItemDropOnDay({
|
||||||
setIsDragging, setModalText, setModalCallback, setIsLoading, modal,
|
setIsDragging,
|
||||||
|
setModalText,
|
||||||
|
setModalCallback,
|
||||||
|
setIsLoading,
|
||||||
|
modal,
|
||||||
}: {
|
}: {
|
||||||
setIsDragging: Dispatch<SetStateAction<boolean>>;
|
setIsDragging: Dispatch<SetStateAction<boolean>>;
|
||||||
setModalText: Dispatch<SetStateAction<string>>;
|
setModalText: Dispatch<SetStateAction<string>>;
|
||||||
setModalCallback: Dispatch<SetStateAction<() => void>>;
|
setModalCallback: Dispatch<SetStateAction<() => void>>;
|
||||||
setIsLoading: Dispatch<SetStateAction<boolean>>;
|
setIsLoading: Dispatch<SetStateAction<boolean>>;
|
||||||
modal: { isOpen: boolean; openModal: () => void; closeModal: () => void; };
|
modal: { isOpen: boolean; openModal: () => void; closeModal: () => void };
|
||||||
}) {
|
}) {
|
||||||
const { data: settings } = useLocalCourseSettingsQuery();
|
const { data: settings } = useLocalCourseSettingsQuery();
|
||||||
const { data: weeks } = useLecturesByWeekQuery();
|
const { data: weeks } = useLecturesByWeekQuery();
|
||||||
@@ -30,6 +40,7 @@ export function useItemDropOnDay({
|
|||||||
const updateLectureMutation = useLectureUpdateMutation();
|
const updateLectureMutation = useLectureUpdateMutation();
|
||||||
const updateAssignmentMutation = useUpdateAssignmentMutation();
|
const updateAssignmentMutation = useUpdateAssignmentMutation();
|
||||||
const updatePageMutation = useUpdatePageMutation();
|
const updatePageMutation = useUpdatePageMutation();
|
||||||
|
|
||||||
return useCallback(
|
return useCallback(
|
||||||
(e: DragEvent, day: string) => {
|
(e: DragEvent, day: string) => {
|
||||||
const rawData = e.dataTransfer.getData("draggableItem");
|
const rawData = e.dataTransfer.getData("draggableItem");
|
||||||
@@ -66,7 +77,11 @@ export function useItemDropOnDay({
|
|||||||
if (existingLecture) {
|
if (existingLecture) {
|
||||||
console.log("attempting to drop on existing lecture");
|
console.log("attempting to drop on existing lecture");
|
||||||
setModalText(
|
setModalText(
|
||||||
`Are you sure you want to replace ${existingLecture?.name} with ${lecture.name}? This will delete ${existingLecture.name}.`
|
`Are you sure you want to replace ${
|
||||||
|
existingLecture?.name || "Un-named Lecture"
|
||||||
|
} with ${lecture.name}? This will delete ${
|
||||||
|
existingLecture?.name || "Un-named Lecture"
|
||||||
|
}.`
|
||||||
);
|
);
|
||||||
|
|
||||||
setModalCallback(() => async () => {
|
setModalCallback(() => async () => {
|
||||||
@@ -81,7 +96,7 @@ export function useItemDropOnDay({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
setModalText("");
|
setModalText("");
|
||||||
setModalCallback(() => { });
|
setModalCallback(() => {});
|
||||||
modal.closeModal();
|
modal.closeModal();
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user