diff --git a/src/components/CourseView.tsx b/src/components/CourseView.tsx index 30e17ea..ddab735 100644 --- a/src/components/CourseView.tsx +++ b/src/components/CourseView.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react'; -import { ArrowLeft, BookOpen, ChevronRight, FileText, CheckCircle2, Circle, MessageSquare, AlertCircle, Award, Download } from 'lucide-react'; +import { ArrowLeft, BookOpen, ChevronRight, ChevronLeft, FileText, CheckCircle2, Circle, MessageSquare, AlertCircle, Award, Download } from 'lucide-react'; import VideoPlayer from './VideoPlayer'; import CourseActivity from './CourseActivity'; @@ -297,6 +297,13 @@ export default function CourseView({ courseId, token, onBack, initialLessonId }: ); } + // Derived state for prev/next lesson + const allLessons = modules.flatMap(m => m.lessons); + const activeLessonIndex = activeLesson ? allLessons.findIndex(l => l.id === activeLesson.id) : -1; + const prevLesson = activeLessonIndex > 0 ? allLessons[activeLessonIndex - 1] : null; + const nextLesson = activeLessonIndex >= 0 && activeLessonIndex < allLessons.length - 1 ? allLessons[activeLessonIndex + 1] : null; + const isCurrentLessonCompleted = activeLesson?.progress?.completed; + return (