diff --git a/nextjs/src/app/course/[courseName]/calendar/day/DayTitle.tsx b/nextjs/src/app/course/[courseName]/calendar/day/DayTitle.tsx index ececcc4..09b60d7 100644 --- a/nextjs/src/app/course/[courseName]/calendar/day/DayTitle.tsx +++ b/nextjs/src/app/course/[courseName]/calendar/day/DayTitle.tsx @@ -15,6 +15,8 @@ export function DayTitle({ day, dayAsDate }: { day: string; dayAsDate: Date }) { const todaysLecture = getLectureForDay(weeks, dayAsDate); const modal = useModal(); + const lectureName = todaysLecture && (todaysLecture.name || "lecture"); + return (
- {dayAsDate.getDate()} {todaysLecture?.name} + {dayAsDate.getDate()} {lectureName} >; setModalText: Dispatch>; setModalCallback: Dispatch void>>; setIsLoading: Dispatch>; - modal: { isOpen: boolean; openModal: () => void; closeModal: () => void; }; + modal: { isOpen: boolean; openModal: () => void; closeModal: () => void }; }) { const { data: settings } = useLocalCourseSettingsQuery(); const { data: weeks } = useLecturesByWeekQuery(); @@ -30,6 +40,7 @@ export function useItemDropOnDay({ const updateLectureMutation = useLectureUpdateMutation(); const updateAssignmentMutation = useUpdateAssignmentMutation(); const updatePageMutation = useUpdatePageMutation(); + return useCallback( (e: DragEvent, day: string) => { const rawData = e.dataTransfer.getData("draggableItem"); @@ -66,7 +77,11 @@ export function useItemDropOnDay({ if (existingLecture) { console.log("attempting to drop on existing lecture"); 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 () => { @@ -81,7 +96,7 @@ export function useItemDropOnDay({ }, }); setModalText(""); - setModalCallback(() => { }); + setModalCallback(() => {}); modal.closeModal(); setIsLoading(false); });