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:
2026-04-07 12:38:46 +05:00
parent 05dd4d1df2
commit 07b9a6d261
8 changed files with 304 additions and 127 deletions
+81 -36
View File
@@ -6,9 +6,6 @@ import StarterKit from "@tiptap/starter-kit";
import Image from "@tiptap/extension-image";
import Link from "@tiptap/extension-link";
import Placeholder from "@tiptap/extension-placeholder";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Button } from "@/components/ui/button";
import { saveLesson } from "@/app/admin/courses/[courseId]/modules/[moduleId]/lessons/[lessonId]/actions";
interface LessonData {
@@ -35,6 +32,16 @@ export function LessonEditor({
const [saved, setSaved] = useState(false);
const [pending, startTransition] = useTransition();
const inputStyle = {
border: "2px solid var(--border)",
background: "var(--background)",
outline: "none",
width: "100%",
padding: "0.5rem 0.75rem",
fontSize: "0.875rem",
fontFamily: "inherit",
} as React.CSSProperties;
const editor = useEditor({
extensions: [
StarterKit,
@@ -86,70 +93,103 @@ export function LessonEditor({
<div className="space-y-5">
{/* Header controls */}
<div className="flex items-center justify-between">
<div className="flex items-center gap-3">
<button
type="button"
role="switch"
aria-checked={published}
onClick={() => setPublished(!published)}
className={`relative w-10 h-6 rounded-full transition-colors ${published ? "bg-green-500" : "bg-slate-300"}`}
<button
type="button"
role="switch"
aria-checked={published}
onClick={() => setPublished(!published)}
className="flex items-center gap-2 text-sm"
>
<span
className="relative inline-block w-10 h-6 transition-colors"
style={{
background: published ? "var(--accent)" : "var(--border)",
border: "2px solid var(--foreground)",
}}
>
<span className={`absolute top-1 left-1 w-4 h-4 bg-white rounded-full shadow transition-transform ${published ? "translate-x-4" : ""}`} />
</button>
<span className="text-sm text-slate-600">{published ? "Опубликован" : "Черновик"}</span>
</div>
<Button onClick={handleSave} disabled={pending || uploading}>
<span
className="absolute top-0.5 w-4 h-4 transition-transform"
style={{
background: "var(--foreground)",
left: "2px",
transform: published ? "translateX(16px)" : "translateX(0)",
}}
/>
</span>
<span style={{ color: published ? "var(--foreground)" : "var(--muted-foreground)" }}>
{published ? "Опубликован" : "Черновик"}
</span>
</button>
<button
type="button"
onClick={handleSave}
disabled={pending || uploading}
className="btn-aubade btn-aubade-accent px-5 py-2 text-sm"
style={{ opacity: pending || uploading ? 0.6 : 1 }}
>
{pending ? "Сохранение..." : saved ? "✓ Сохранено" : "Сохранить урок"}
</Button>
</button>
</div>
{/* Title */}
<div className="space-y-1.5">
<Label htmlFor="lesson-title">Заголовок урока</Label>
<Input
id="lesson-title"
<div className="space-y-1">
<label className="text-xs font-bold uppercase tracking-widest" style={{ color: "var(--muted-foreground)" }}>
Заголовок урока
</label>
<input
value={title}
onChange={(e) => setTitle(e.target.value)}
className="text-lg font-medium"
style={{ ...inputStyle, fontSize: "1.1rem", fontWeight: "700" }}
onFocus={(e) => (e.currentTarget.style.borderColor = "var(--foreground)")}
onBlur={(e) => (e.currentTarget.style.borderColor = "var(--border)")}
/>
</div>
{/* Kinescope ID */}
<div className="space-y-1.5">
<Label htmlFor="kinescope-id">Kinescope ID</Label>
<Input
id="kinescope-id"
<div className="space-y-1">
<label className="text-xs font-bold uppercase tracking-widest" style={{ color: "var(--muted-foreground)" }}>
Kinescope Video ID
</label>
<input
value={kinescopeId}
onChange={(e) => setKinescopeId(e.target.value)}
placeholder="Оставьте пустым если видео нет"
className="font-mono text-sm"
style={{ ...inputStyle, fontFamily: "var(--font-mono)" }}
onFocus={(e) => (e.currentTarget.style.borderColor = "var(--foreground)")}
onBlur={(e) => (e.currentTarget.style.borderColor = "var(--border)")}
/>
</div>
{/* TipTap Editor */}
<div className="space-y-1.5">
<Label>Содержимое урока</Label>
<div className="space-y-1">
<label className="text-xs font-bold uppercase tracking-widest" style={{ color: "var(--muted-foreground)" }}>
Содержимое урока
</label>
{/* Toolbar */}
<div className="flex flex-wrap gap-1 p-2 bg-slate-50 border border-slate-200 rounded-t-lg border-b-0">
<div
className="flex flex-wrap gap-1 p-2"
style={{ border: "2px solid var(--border)", borderBottom: "1px solid var(--border)", background: "var(--color-surface)" }}
>
<ToolBtn onClick={() => editor?.chain().focus().toggleBold().run()} active={editor?.isActive("bold")}>Ж</ToolBtn>
<ToolBtn onClick={() => editor?.chain().focus().toggleItalic().run()} active={editor?.isActive("italic")}><em>К</em></ToolBtn>
<ToolBtn onClick={() => editor?.chain().focus().toggleHeading({ level: 2 }).run()} active={editor?.isActive("heading", { level: 2 })}>H2</ToolBtn>
<ToolBtn onClick={() => editor?.chain().focus().toggleHeading({ level: 3 }).run()} active={editor?.isActive("heading", { level: 3 })}>H3</ToolBtn>
<div className="w-px bg-slate-200 mx-1" />
<div className="w-px mx-1" style={{ background: "var(--border)" }} />
<ToolBtn onClick={() => editor?.chain().focus().toggleBulletList().run()} active={editor?.isActive("bulletList")}> Список</ToolBtn>
<ToolBtn onClick={() => editor?.chain().focus().toggleOrderedList().run()} active={editor?.isActive("orderedList")}>1. Список</ToolBtn>
<ToolBtn onClick={() => editor?.chain().focus().toggleBlockquote().run()} active={editor?.isActive("blockquote")}>&ldquo;&rdquo;</ToolBtn>
<ToolBtn onClick={() => editor?.chain().focus().toggleCodeBlock().run()} active={editor?.isActive("codeBlock")}>{'</>'}</ToolBtn>
<div className="w-px bg-slate-200 mx-1" />
<div className="w-px mx-1" style={{ background: "var(--border)" }} />
<ToolBtn onClick={uploadImage} disabled={uploading}>{uploading ? "Загрузка..." : "🖼 Фото"}</ToolBtn>
<div className="w-px bg-slate-200 mx-1" />
<div className="w-px mx-1" style={{ background: "var(--border)" }} />
<ToolBtn onClick={() => editor?.chain().focus().undo().run()}></ToolBtn>
<ToolBtn onClick={() => editor?.chain().focus().redo().run()}></ToolBtn>
</div>
{/* Editor content */}
<div className="border border-slate-200 rounded-b-lg bg-white">
<div style={{ border: "2px solid var(--border)", borderTop: "none", background: "var(--background)" }}>
<EditorContent editor={editor} />
</div>
</div>
@@ -173,9 +213,14 @@ function ToolBtn({
type="button"
onClick={onClick}
disabled={disabled}
className={`px-2 py-1 text-sm rounded transition-colors ${
active ? "bg-slate-700 text-white" : "hover:bg-slate-200 text-slate-700"
} disabled:opacity-50`}
className="px-2 py-1 text-xs transition-colors disabled:opacity-50"
style={{
background: active ? "var(--foreground)" : "transparent",
color: active ? "var(--background)" : "var(--foreground)",
border: "1px solid transparent",
}}
onMouseEnter={(e) => { if (!active) e.currentTarget.style.background = "var(--border)"; }}
onMouseLeave={(e) => { if (!active) e.currentTarget.style.background = "transparent"; }}
>
{children}
</button>