mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
view todays lectures from home
This commit is contained in:
34
nextjs/src/app/todaysLectures/OneCourseLectures.tsx
Normal file
34
nextjs/src/app/todaysLectures/OneCourseLectures.tsx
Normal file
@@ -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 (
|
||||
<Link
|
||||
href={getLecturePreviewUrl(courseName, dayAsString)}
|
||||
className="
|
||||
border-4 rounded-lg border-slate-500
|
||||
p-3 m-3 block text-end
|
||||
bg-slate-950
|
||||
transition-all hover:scale-110 hover:shadow-md
|
||||
"
|
||||
>
|
||||
<span className="font-bold text-xl">{todaysLecture?.name}</span>
|
||||
<br />
|
||||
<span className="text-slate-500">{courseName}</span>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user