'use client'; import { ChevronDown, ChevronRight, FileText, Plus } from 'lucide-react'; import { useState } from 'react'; import { cn } from '@/lib/utils'; import { Button } from '@/components/ui/button'; interface Lesson { id: string; title: string; } interface Chapter { id: string; title: string; lessons: Lesson[]; } interface Course { id: string; title: string; chapters: Chapter[]; } interface LessonSidebarProps { course: Course; activeLesson: string; onSelectLesson: (lessonId: string) => void; /** Скрыть кнопки «Добавить урок/главу» (режим просмотра) */ readOnly?: boolean; } export function LessonSidebar({ course, activeLesson, onSelectLesson, readOnly = false, }: LessonSidebarProps) { const [expandedChapters, setExpandedChapters] = useState( course.chapters.map((ch) => ch.id) ); const toggleChapter = (chapterId: string) => { setExpandedChapters((prev) => prev.includes(chapterId) ? prev.filter((id) => id !== chapterId) : [...prev, chapterId] ); }; return (
{/* Header */}

{course.title}

{/* Chapters list */}
{course.chapters.map((chapter) => { const isExpanded = expandedChapters.includes(chapter.id); return (
{/* Chapter header */} {/* Lessons */} {isExpanded && (
{chapter.lessons.map((lesson) => ( ))} {!readOnly && ( )}
)}
); })}
{!readOnly && (
)}
); }