diff --git a/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/EditLectureTitle.tsx b/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/EditLectureTitle.tsx
new file mode 100644
index 0000000..04fee3c
--- /dev/null
+++ b/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/EditLectureTitle.tsx
@@ -0,0 +1,47 @@
+import { useLocalCourseSettingsQuery } from "@/hooks/localCourse/localCoursesHooks";
+import { getDayOfWeek } from "@/models/local/localCourse";
+import { getDateFromString } from "@/models/local/timeUtils";
+import { getLectureWeekName } from "@/services/fileStorage/utils/lectureUtils";
+import { getCourseUrl, getLecturePreviewUrl } from "@/services/urlUtils";
+import { useRouter } from "next/navigation";
+import { useCourseContext } from "../../context/courseContext";
+import Link from "next/link";
+
+export default function EditLectureTitle({
+ lectureDay,
+}: {
+ lectureDay: string;
+}) {
+ const router = useRouter();
+ const { data: settings } = useLocalCourseSettingsQuery();
+ const { courseName } = useCourseContext();
+ const lectureDate = getDateFromString(lectureDay);
+ const lectureWeekName = getLectureWeekName(settings.startDate, lectureDay);
+ return (
+
+
+
+ {courseName}
+
+
+
+
Lecture
+
+ {lectureDate && getDayOfWeek(lectureDate)}{" "}
+ {lectureWeekName.toUpperCase()}
+
+
+
+
+ preview
+
+
+
+ );
+}
diff --git a/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/LecturePreview.tsx b/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/LecturePreview.tsx
index 046a8a4..076b791 100644
--- a/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/LecturePreview.tsx
+++ b/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/LecturePreview.tsx
@@ -3,16 +3,10 @@ import { markdownToHTMLSafe } from "@/services/htmlMarkdownUtils";
export default function LecturePreview({ lecture }: { lecture: Lecture }) {
return (
-
-
-
-
Name
-
{lecture.name}
-
-
-
Date
-
{lecture.date}
-
+ <>
+
+ {lecture.name}
+ {lecture.date}
-
+ >
);
}
diff --git a/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/page.tsx b/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/page.tsx
index 08598b0..03abe22 100644
--- a/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/page.tsx
+++ b/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/page.tsx
@@ -1,4 +1,3 @@
-import React from "react";
import EditLecture from "./EditLecture";
import { getDateFromStringOrThrow, getDateOnlyMarkdownString } from "@/models/local/timeUtils";
diff --git a/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/preview/LecturePreviewPage.tsx b/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/preview/LecturePreviewPage.tsx
new file mode 100644
index 0000000..6db2d28
--- /dev/null
+++ b/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/preview/LecturePreviewPage.tsx
@@ -0,0 +1,44 @@
+"use client";
+
+import { useLecturesByWeekQuery } from "@/hooks/localCourse/lectureHooks";
+import LecturePreview from "../LecturePreview";
+import { getLectureUrl } from "@/services/urlUtils";
+import { useCourseContext } from "../../../context/courseContext";
+import Link from "next/link";
+
+export default function LecturePreviewPage({
+ lectureDay,
+}: {
+ lectureDay: string;
+}) {
+ const { courseName } = useCourseContext();
+ const { data: weeks } = useLecturesByWeekQuery();
+ const lecture = weeks
+ .flatMap(({ lectures }) => lectures.map((lecture) => lecture))
+ .find((l) => l.date === lectureDay);
+
+ if (!lecture) {
+ return
lecture not found for day
;
+ }
+ return (
+
+
+
+ Edit Page
+
+
+
+
+
+ );
+}
diff --git a/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/preview/page.tsx b/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/preview/page.tsx
new file mode 100644
index 0000000..5c291a0
--- /dev/null
+++ b/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/preview/page.tsx
@@ -0,0 +1,21 @@
+import {
+ getDateFromStringOrThrow,
+ getDateOnlyMarkdownString,
+} from "@/models/local/timeUtils";
+import LecturePreviewPage from "./LecturePreviewPage";
+
+export default function Page({
+ params: { lectureDay },
+}: {
+ params: { lectureDay: string };
+}) {
+ const decodedLectureDay = decodeURIComponent(lectureDay);
+ console.log(decodedLectureDay);
+ const lectureDate = getDateFromStringOrThrow(
+ decodedLectureDay,
+ "lecture day in lecture page"
+ );
+ const lectureDayOnly = getDateOnlyMarkdownString(lectureDate);
+
+ return
;
+}
diff --git a/nextjs/src/services/fileStorage/lectureFileStorageService.ts b/nextjs/src/services/fileStorage/lectureFileStorageService.ts
index b3ee2dd..b679215 100644
--- a/nextjs/src/services/fileStorage/lectureFileStorageService.ts
+++ b/nextjs/src/services/fileStorage/lectureFileStorageService.ts
@@ -3,6 +3,7 @@ import path from "path";
import { basePath } from "./utils/fileSystemUtils";
import fs from "fs/promises";
import {
+ getLectureWeekName,
lectureFolderName,
lectureToString,
parseLecture,
@@ -51,19 +52,12 @@ export async function updateLecture(
lecture: Lecture
) {
const courseLectureRoot = path.join(basePath, courseName, lectureFolderName);
- const startDate = getDateFromStringOrThrow(
- courseSettings.startDate,
- "semester start date in update lecture"
- );
const lectureDate = getDateFromStringOrThrow(
lecture.date,
"lecture start date in update lecture"
);
- const weekNumber = getWeekNumber(startDate, lectureDate)
- .toString()
- .padStart(2, "0");
- const weekFolderName = `week-${weekNumber}`;
+ const weekFolderName = getLectureWeekName(courseSettings.startDate, lecture.date);
const weekPath = path.join(courseLectureRoot, weekFolderName);
if (!(await directoryExists(weekPath))) {
await fs.mkdir(weekPath, { recursive: true });
diff --git a/nextjs/src/services/fileStorage/utils/lectureUtils.ts b/nextjs/src/services/fileStorage/utils/lectureUtils.ts
index fb38761..ec96dd1 100644
--- a/nextjs/src/services/fileStorage/utils/lectureUtils.ts
+++ b/nextjs/src/services/fileStorage/utils/lectureUtils.ts
@@ -1,5 +1,7 @@
+import { getWeekNumber } from "@/app/course/[courseName]/calendar/calendarMonthUtils";
import { extractLabelValue } from "@/models/local/assignment/utils/markdownUtils";
import { Lecture } from "@/models/local/lecture";
+import { getDateFromStringOrThrow } from "@/models/local/timeUtils";
export function parseLecture(fileContent: string): Lecture {
try {
@@ -27,4 +29,21 @@ Date: ${lecture.date}
${lecture.content}`;
}
-export const lectureFolderName = "00 - lectures"
\ No newline at end of file
+export const lectureFolderName = "00 - lectures";
+
+export function getLectureWeekName(semesterStart: string, lectureDate: string) {
+ const startDate = getDateFromStringOrThrow(
+ semesterStart,
+ "semester start date in update lecture"
+ );
+ const targetDate = getDateFromStringOrThrow(
+ lectureDate,
+ "lecture start date in update lecture"
+ );
+ const weekNumber = getWeekNumber(startDate, targetDate)
+ .toString()
+ .padStart(2, "0");
+
+ const weekName = `week-${weekNumber}`;
+ return weekName;
+}
diff --git a/nextjs/src/services/urlUtils.ts b/nextjs/src/services/urlUtils.ts
index c2d72e8..6aa21d9 100644
--- a/nextjs/src/services/urlUtils.ts
+++ b/nextjs/src/services/urlUtils.ts
@@ -21,6 +21,9 @@ export function getLectureUrl(courseName: string, lectureDate: string) {
encodeURIComponent(lectureDate)
);
}
+export function getLecturePreviewUrl(courseName: string, lectureDate: string) {
+ return getLectureUrl(courseName, lectureDate) + "/preview";
+}
export function getCourseUrl(courseName: string) {
return "/course/" + encodeURIComponent(courseName);