Polish UX: auto-redirect on create, fix design consistency
- createModule now redirects to module page after creation - createLesson now redirects to lesson editor after creation - Regenerate Prisma client to fix missing types (category, accessLog, expiresAt) - Rewrite sortable-modules/lessons with Second Brain design tokens (remove amber/slate) - Rewrite lesson-editor toolbar and toggle with design tokens - Fix register page/form: replace amber theme with card-aubade design Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import { prisma } from "@/lib/prisma";
|
||||
import { headers } from "next/headers";
|
||||
import { auth } from "@/lib/auth";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
async function requireAdmin() {
|
||||
const session = await auth.api.getSession({ headers: await headers() });
|
||||
@@ -14,8 +15,9 @@ export async function createLesson(moduleId: string, courseId: string, formData:
|
||||
await requireAdmin();
|
||||
const title = formData.get("title") as string;
|
||||
const count = await prisma.lesson.count({ where: { moduleId } });
|
||||
await prisma.lesson.create({ data: { moduleId, title, order: count } });
|
||||
const lesson = await prisma.lesson.create({ data: { moduleId, title, order: count } });
|
||||
revalidatePath(`/admin/courses/${courseId}/modules/${moduleId}`);
|
||||
redirect(`/admin/courses/${courseId}/modules/${moduleId}/lessons/${lesson.id}`);
|
||||
}
|
||||
|
||||
export async function updateLesson(lessonId: string, courseId: string, moduleId: string, formData: FormData) {
|
||||
|
||||
Reference in New Issue
Block a user