Debug: add try/catch and JSON sanitize in saveLesson

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-25 17:54:10 +05:00
parent 65aa669522
commit 8757537344
+6 -1
View File
@@ -22,15 +22,20 @@ export async function saveLesson(
}
) {
await requireAdmin();
try {
await prisma.lesson.update({
where: { id: lessonId },
data: {
title: data.title,
kinescopeId: data.kinescopeId || null,
content: data.content,
content: JSON.parse(JSON.stringify(data.content)),
published: data.published,
},
});
} catch (err) {
console.error("[saveLesson] full error:", err);
throw err;
}
revalidatePath(`/admin/courses/${courseId}/modules/${moduleId}`);
revalidatePath(`/admin/courses/${courseId}/modules/${moduleId}/lessons/${lessonId}`);
}