import React, { useState } from 'react'; import { Button } from '../ui/button'; import { ProgressBar } from '../ui/progress'; import { Course } from '../../types'; import { ChevronLeft, ChevronRight, CheckCircle, PlayCircle, FileText, HelpCircle, Menu, X, } from 'lucide-react'; import { useToast } from '../../context/ToastContext'; import { QuizModal } from './modals/QuizModal'; import { CertificateModal } from './modals/CertificateModal'; interface CourseLearningViewProps { course: Course; onBack: () => void; } export const CourseLearningView: React.FC = ({ course, onBack, }) => { const { addToast } = useToast(); const [activeLessonId, setActiveLessonId] = useState( course.modules?.[0]?.lessons[0]?.id || '', ); const [completedLessons, setCompletedLessons] = useState([]); const [sidebarOpen, setSidebarOpen] = useState(true); const [activeTab, setActiveTab] = useState< 'overview' | 'notes' | 'resources' >('overview'); // Quiz State const [showQuiz, setShowQuiz] = useState(false); const [activeQuiz, setActiveQuiz] = useState(null); // Certificate State const [showCertificate, setShowCertificate] = useState(false); // Flattened lessons for navigation const allLessons = course.modules?.flatMap((m) => m.lessons) || []; const currentLessonIndex = allLessons.findIndex( (l) => l.id === activeLessonId, ); const currentLesson = allLessons[currentLessonIndex]; const handleNext = () => { if (currentLessonIndex < allLessons.length - 1) { const nextLesson = allLessons[currentLessonIndex + 1]; setActiveLessonId(nextLesson.id); markComplete(currentLesson.id); } else { // Course finished markComplete(currentLesson.id); addToast('Course Completed! 🎉', 'success'); if (course.certificateAvailable) { setShowCertificate(true); } } }; const handlePrev = () => { if (currentLessonIndex > 0) { setActiveLessonId(allLessons[currentLessonIndex - 1].id); } }; const markComplete = (id: string) => { if (!completedLessons.includes(id)) { setCompletedLessons([...completedLessons, id]); } }; const startQuiz = (quizId: string) => { // Mock Quiz Data setActiveQuiz({ id: quizId, title: 'Module Assessment', passingScore: 70, questions: [ { id: 'q1', question: 'What is the frequency range of a sub-bass?', options: ['20-60Hz', '200-500Hz', '1-2kHz'], correctIndex: 0, }, { id: 'q2', question: 'Which plugin is best for sidechaining?', options: ['Reverb', 'Compressor', 'Delay'], correctIndex: 1, }, ], }); setShowQuiz(true); }; const progress = Math.round( (completedLessons.length / allLessons.length) * 100, ); return (
{/* Header Bar */}

{course.title}

{progress}% Complete
{/* Main Content Area */}
{/* Player Stage */}
{currentLesson?.type === 'video' ? (

Video Player Placeholder

{currentLesson.title}

) : currentLesson?.type === 'quiz' ? (

Quiz: {currentLesson.title}

) : (

{currentLesson?.title}

{currentLesson?.content || 'This is a text-based lesson. Content would be rendered here in Markdown.'}

)}
{/* Tabs & Meta */}

{currentLesson?.title}

{['overview', 'notes', 'resources'].map((tab) => ( ))}
{activeTab === 'overview' && (

In this lesson, we cover the fundamentals of the topic. Make sure to take notes.

Key Takeaways

  • Understanding the core concept
  • Applying technique A to situation B
  • Common pitfalls to avoid
)} {activeTab === 'notes' && (