Serialize all Prisma proxy data in admin lesson and module pages
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -36,6 +36,17 @@ export default async function LessonEditorPage({ params }: Props) {
|
|||||||
const prevLesson = idx > 0 ? siblings[idx - 1] : null;
|
const prevLesson = idx > 0 ? siblings[idx - 1] : null;
|
||||||
const nextLesson = idx < siblings.length - 1 ? siblings[idx + 1] : null;
|
const nextLesson = idx < siblings.length - 1 ? siblings[idx + 1] : null;
|
||||||
|
|
||||||
|
// Serialize all Prisma proxy objects (DateTime, relations) before passing to Client Components
|
||||||
|
const plain = JSON.parse(JSON.stringify({
|
||||||
|
files: lesson.files,
|
||||||
|
homework: lesson.homework,
|
||||||
|
siblings,
|
||||||
|
})) as {
|
||||||
|
files: typeof lesson.files;
|
||||||
|
homework: typeof lesson.homework;
|
||||||
|
siblings: typeof siblings;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-8 max-w-4xl">
|
<div className="p-8 max-w-4xl">
|
||||||
<nav className="text-xs mb-6 uppercase tracking-widest" style={{ color: "var(--muted-foreground)" }}>
|
<nav className="text-xs mb-6 uppercase tracking-widest" style={{ color: "var(--muted-foreground)" }}>
|
||||||
@@ -61,8 +72,8 @@ export default async function LessonEditorPage({ params }: Props) {
|
|||||||
courseId={courseId}
|
courseId={courseId}
|
||||||
moduleId={moduleId}
|
moduleId={moduleId}
|
||||||
courseSlug={lesson.module.course.slug}
|
courseSlug={lesson.module.course.slug}
|
||||||
prevLesson={prevLesson}
|
prevLesson={plain.siblings[idx - 1] ?? null}
|
||||||
nextLesson={nextLesson}
|
nextLesson={plain.siblings[idx + 1] ?? null}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -71,7 +82,7 @@ export default async function LessonEditorPage({ params }: Props) {
|
|||||||
<p className="text-xs font-bold uppercase tracking-widest mb-4" style={{ color: "var(--muted-foreground)" }}>
|
<p className="text-xs font-bold uppercase tracking-widest mb-4" style={{ color: "var(--muted-foreground)" }}>
|
||||||
Файлы и материалы
|
Файлы и материалы
|
||||||
</p>
|
</p>
|
||||||
<LessonFilesManager lessonId={lessonId} initialFiles={lesson.files} />
|
<LessonFilesManager lessonId={lessonId} initialFiles={plain.files} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Homework section */}
|
{/* Homework section */}
|
||||||
@@ -79,7 +90,7 @@ export default async function LessonEditorPage({ params }: Props) {
|
|||||||
<p className="text-xs font-bold uppercase tracking-widest mb-4" style={{ color: "var(--muted-foreground)" }}>
|
<p className="text-xs font-bold uppercase tracking-widest mb-4" style={{ color: "var(--muted-foreground)" }}>
|
||||||
Домашнее задание
|
Домашнее задание
|
||||||
</p>
|
</p>
|
||||||
<HomeworkEditor lessonId={lessonId} initial={lesson.homework} />
|
<HomeworkEditor lessonId={lessonId} initial={plain.homework} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -30,6 +30,11 @@ export default async function ModulePage({ params }: Props) {
|
|||||||
|
|
||||||
if (!module || module.courseId !== courseId) notFound();
|
if (!module || module.courseId !== courseId) notFound();
|
||||||
|
|
||||||
|
const plain = JSON.parse(JSON.stringify({ lessons: module.lessons, allModules })) as {
|
||||||
|
lessons: typeof module.lessons;
|
||||||
|
allModules: typeof allModules;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-8 max-w-3xl">
|
<div className="p-8 max-w-3xl">
|
||||||
<nav className="text-xs mb-6 uppercase tracking-widest" style={{ color: "var(--muted-foreground)" }}>
|
<nav className="text-xs mb-6 uppercase tracking-widest" style={{ color: "var(--muted-foreground)" }}>
|
||||||
@@ -54,8 +59,8 @@ export default async function ModulePage({ params }: Props) {
|
|||||||
<SortableLessons
|
<SortableLessons
|
||||||
courseId={courseId}
|
courseId={courseId}
|
||||||
moduleId={moduleId}
|
moduleId={moduleId}
|
||||||
lessons={module.lessons}
|
lessons={plain.lessons}
|
||||||
otherModules={allModules}
|
otherModules={plain.allModules}
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user