From b5dc5794111551f6d7cb4f2e8276a69aaf350f5b Mon Sep 17 00:00:00 2001 From: Alex Mickelson Date: Sat, 2 Nov 2024 12:43:31 -0600 Subject: [PATCH] view todays lectures from home --- nextjs/src/app/CourseList.tsx | 9 ++++- nextjs/src/app/newCourse/AddNewCourse.tsx | 6 +++- nextjs/src/app/page.tsx | 14 ++++++-- .../app/todaysLectures/OneCourseLectures.tsx | 34 +++++++++++++++++++ .../src/app/todaysLectures/TodaysLectures.tsx | 26 ++++++++++++++ 5 files changed, 85 insertions(+), 4 deletions(-) create mode 100644 nextjs/src/app/todaysLectures/OneCourseLectures.tsx create mode 100644 nextjs/src/app/todaysLectures/TodaysLectures.tsx diff --git a/nextjs/src/app/CourseList.tsx b/nextjs/src/app/CourseList.tsx index 68e440a..7692889 100644 --- a/nextjs/src/app/CourseList.tsx +++ b/nextjs/src/app/CourseList.tsx @@ -9,7 +9,14 @@ export default function CourseList() {
{allSettings.map((settings) => (
- + {settings.name}
diff --git a/nextjs/src/app/newCourse/AddNewCourse.tsx b/nextjs/src/app/newCourse/AddNewCourse.tsx index 4feb587..95d0375 100644 --- a/nextjs/src/app/newCourse/AddNewCourse.tsx +++ b/nextjs/src/app/newCourse/AddNewCourse.tsx @@ -9,7 +9,11 @@ export default function AddNewCourse() { return (
- +
+ +
diff --git a/nextjs/src/app/page.tsx b/nextjs/src/app/page.tsx index d450f49..db686e1 100644 --- a/nextjs/src/app/page.tsx +++ b/nextjs/src/app/page.tsx @@ -1,11 +1,21 @@ import CourseList from "./CourseList"; import AddNewCourse from "./newCourse/AddNewCourse"; +import TodaysLectures from "./todaysLectures/TodaysLectures"; export default async function Home() { return (
-
- +
+
+
+
+
+
+ +
+
+
+

diff --git a/nextjs/src/app/todaysLectures/OneCourseLectures.tsx b/nextjs/src/app/todaysLectures/OneCourseLectures.tsx new file mode 100644 index 0000000..2e8ca6e --- /dev/null +++ b/nextjs/src/app/todaysLectures/OneCourseLectures.tsx @@ -0,0 +1,34 @@ +"use client"; + +import { useLecturesByWeekQuery } from "@/hooks/localCourse/lectureHooks"; +import { getDateOnlyMarkdownString } from "@/models/local/timeUtils"; +import { getLecturePreviewUrl } from "@/services/urlUtils"; +import Link from "next/link"; +import { useCourseContext } from "../course/[courseName]/context/courseContext"; + +export default function OneCourseLectures() { + const { courseName } = useCourseContext(); + const { data: weeks } = useLecturesByWeekQuery(); + + const dayAsDate = new Date(); + const dayAsString = getDateOnlyMarkdownString(dayAsDate); + const todaysLecture = weeks + .flatMap((w) => w.lectures) + .find((l) => l.date == dayAsString); + if (!todaysLecture) return <>; + return ( + + {todaysLecture?.name} +
+ {courseName} + + ); +} diff --git a/nextjs/src/app/todaysLectures/TodaysLectures.tsx b/nextjs/src/app/todaysLectures/TodaysLectures.tsx new file mode 100644 index 0000000..e96bacd --- /dev/null +++ b/nextjs/src/app/todaysLectures/TodaysLectures.tsx @@ -0,0 +1,26 @@ +"use client"; + +import { useLocalCoursesSettingsQuery } from "@/hooks/localCourse/localCoursesHooks"; +import OneCourseLectures from "./OneCourseLectures"; +import { SuspenseAndErrorHandling } from "@/components/SuspenseAndErrorHandling"; +import CourseContextProvider from "../course/[courseName]/context/CourseContextProvider"; + +export default function TodaysLectures() { + const { data: allSettings } = useLocalCoursesSettingsQuery(); + return ( +
+ {/*

todays lectures

*/} +
+ + {allSettings.map((settings) => ( +
+ + + +
+ ))} +
+
+
+ ); +}