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 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 (
|
||||
<div className="p-8 max-w-4xl">
|
||||
<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}
|
||||
moduleId={moduleId}
|
||||
courseSlug={lesson.module.course.slug}
|
||||
prevLesson={prevLesson}
|
||||
nextLesson={nextLesson}
|
||||
prevLesson={plain.siblings[idx - 1] ?? null}
|
||||
nextLesson={plain.siblings[idx + 1] ?? null}
|
||||
/>
|
||||
</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>
|
||||
<LessonFilesManager lessonId={lessonId} initialFiles={lesson.files} />
|
||||
<LessonFilesManager lessonId={lessonId} initialFiles={plain.files} />
|
||||
</div>
|
||||
|
||||
{/* 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>
|
||||
<HomeworkEditor lessonId={lessonId} initial={lesson.homework} />
|
||||
<HomeworkEditor lessonId={lessonId} initial={plain.homework} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -30,6 +30,11 @@ export default async function ModulePage({ params }: Props) {
|
||||
|
||||
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 (
|
||||
<div className="p-8 max-w-3xl">
|
||||
<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
|
||||
courseId={courseId}
|
||||
moduleId={moduleId}
|
||||
lessons={module.lessons}
|
||||
otherModules={allModules}
|
||||
lessons={plain.lessons}
|
||||
otherModules={plain.allModules}
|
||||
/>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user