Files
lms-sb/src/app/admin/courses/[courseId]/modules/[moduleId]/page.tsx
T
admins f0024c4243 Add course management improvements: tree view, module descriptions, lesson toggles
- SortableModules: add description textarea in edit form, show description in row
- CourseDetailPage: fetch lessons per module, add CourseTree overview section
- ModulePage: fetch sibling modules, pass as otherModules to SortableLessons

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-08 13:31:30 +05:00

61 lines
2.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { prisma } from "@/lib/prisma";
import { notFound } from "next/navigation";
import Link from "next/link";
import { SortableLessons } from "@/components/admin/sortable-lessons";
interface Props {
params: Promise<{ courseId: string; moduleId: string }>;
}
export default async function ModulePage({ params }: Props) {
const { courseId, moduleId } = await params;
const [module, allModules] = await Promise.all([
prisma.module.findUnique({
where: { id: moduleId },
include: {
course: { select: { title: true } },
lessons: { orderBy: { order: "asc" } },
},
}),
prisma.module.findMany({
where: { courseId, NOT: { id: moduleId } },
select: { id: true, title: true },
orderBy: { order: "asc" },
}),
]);
if (!module || module.courseId !== courseId) notFound();
return (
<div className="p-8 max-w-3xl">
<nav className="text-xs mb-6 uppercase tracking-widest" style={{ color: "var(--muted-foreground)" }}>
<Link href="/admin/courses" className="hover:underline">Курсы</Link>
<span className="mx-2">/</span>
<Link href={`/admin/courses/${courseId}`} className="hover:underline">{module.course.title}</Link>
<span className="mx-2">/</span>
<span style={{ color: "var(--foreground)" }}>{module.title}</span>
</nav>
<div className="mb-6">
<h1 className="text-2xl font-bold">{module.title}</h1>
<p className="text-sm mt-1" style={{ color: "var(--muted-foreground)" }}>
{module.lessons.length} {module.lessons.length === 1 ? "урок" : module.lessons.length < 5 ? "урока" : "уроков"}
</p>
</div>
<section className="card-aubade p-6">
<p className="text-xs font-bold uppercase tracking-widest mb-5" style={{ color: "var(--muted-foreground)" }}>
Уроки модуля
</p>
<SortableLessons
courseId={courseId}
moduleId={moduleId}
lessons={module.lessons}
otherModules={allModules}
/>
</section>
</div>
);
}