Add coverImage poster to player, fix TipTap v3 editor reset, quiz admin preview
- Add coverImage field to Lesson model (prisma) - Pass coverImage as poster prop to KinescopePlayer - Show quiz in read-only preview mode for admin on lesson page - Fix TipTap v3 editor reset on save: pass [lesson.id] as deps to useEditor to prevent setOptions() from reinitializing content on every re-render - Replace saveLesson Server Action call with fetch PATCH /api/admin/lessons/[id] to avoid Next.js 16 automatic RSC refresh after Server Actions - Simplify revalidatePath: only revalidate module page, not lesson editor page
This commit is contained in:
@@ -21,16 +21,29 @@ export async function saveLesson(
|
||||
published: boolean;
|
||||
}
|
||||
) {
|
||||
await requireAdmin();
|
||||
await prisma.lesson.update({
|
||||
where: { id: lessonId },
|
||||
data: {
|
||||
title: data.title,
|
||||
kinescopeId: data.kinescopeId || null,
|
||||
content: JSON.parse(JSON.stringify(data.content)),
|
||||
published: data.published,
|
||||
},
|
||||
});
|
||||
console.log("[saveLesson] start", lessonId);
|
||||
try {
|
||||
await requireAdmin();
|
||||
console.log("[saveLesson] auth ok");
|
||||
} catch (e) {
|
||||
console.error("[saveLesson] auth failed:", e);
|
||||
throw e;
|
||||
}
|
||||
try {
|
||||
await prisma.lesson.update({
|
||||
where: { id: lessonId },
|
||||
data: {
|
||||
title: data.title,
|
||||
kinescopeId: data.kinescopeId || null,
|
||||
content: JSON.parse(JSON.stringify(data.content)),
|
||||
published: data.published,
|
||||
},
|
||||
});
|
||||
console.log("[saveLesson] db update ok");
|
||||
} catch (e) {
|
||||
console.error("[saveLesson] db update failed:", e);
|
||||
throw e;
|
||||
}
|
||||
revalidatePath(`/admin/courses/${courseId}/modules/${moduleId}`);
|
||||
revalidatePath(`/admin/courses/${courseId}/modules/${moduleId}/lessons/${lessonId}`);
|
||||
console.log("[saveLesson] done");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user