Add save and preview icons to lesson editor

- Save button now shows floppy disk icon (lucide Save)
- New Preview button with eye icon opens lesson in student view (new tab)
- Pass courseSlug through to LessonEditor for preview URL construction

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-07 12:45:30 +05:00
parent 07b9a6d261
commit 4183a912e4
2 changed files with 28 additions and 10 deletions
+26 -9
View File
@@ -6,6 +6,7 @@ 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 { Save, Eye } from "lucide-react";
import { saveLesson } from "@/app/admin/courses/[courseId]/modules/[moduleId]/lessons/[lessonId]/actions";
interface LessonData {
@@ -20,10 +21,12 @@ export function LessonEditor({
lesson,
courseId,
moduleId,
courseSlug,
}: {
lesson: LessonData;
courseId: string;
moduleId: string;
courseSlug: string;
}) {
const [title, setTitle] = useState(lesson.title);
const [kinescopeId, setKinescopeId] = useState(lesson.kinescopeId);
@@ -121,15 +124,29 @@ export function LessonEditor({
</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>
<div className="flex items-center gap-2">
<a
href={`/courses/${courseSlug}/lessons/${lesson.id}`}
target="_blank"
rel="noopener noreferrer"
className="btn-aubade flex items-center gap-1.5 px-4 py-2 text-sm"
title="Просмотр как студент"
>
<Eye size={14} />
Просмотр
</a>
<button
type="button"
onClick={handleSave}
disabled={pending || uploading}
className="btn-aubade btn-aubade-accent flex items-center gap-1.5 px-4 py-2 text-sm"
style={{ opacity: pending || uploading ? 0.6 : 1 }}
title="Сохранить урок"
>
<Save size={14} />
{pending ? "Сохранение..." : saved ? "Сохранено" : "Сохранить"}
</button>
</div>
</div>
{/* Title */}