diff --git a/apps/web/src/components/education/CourseLearningView.stories.tsx b/apps/web/src/components/education/CourseLearningView.stories.tsx index 4b39f5e5d..33c1d4d81 100644 --- a/apps/web/src/components/education/CourseLearningView.stories.tsx +++ b/apps/web/src/components/education/CourseLearningView.stories.tsx @@ -1,5 +1,5 @@ import type { Meta, StoryObj } from '@storybook/react'; -import { CourseLearningView } from './CourseLearningView'; +import { CourseLearningView, CourseLearningViewSkeleton } from './CourseLearningView'; const meta: Meta = { title: 'Components/Features/Education/CourseLearningView', @@ -52,6 +52,24 @@ export const Default: Story = { } }; +export const Loading: Story = { + name: 'Chargement', + render: () => , +}; + +export const Empty: Story = { + name: 'Vide (sans leΓ§ons)', + args: { + course: { + ...mockCourse, + modules: [ + { id: 'm1', title: 'Introduction', lessons: [] } + ] + }, + onBack: () => console.log('Back clicked') + } +}; + export const Complete: Story = { name: 'TerminΓ©', args: { diff --git a/apps/web/src/components/education/CourseLearningView.tsx b/apps/web/src/components/education/CourseLearningView.tsx index 111ffd9d4..44cad9d29 100644 --- a/apps/web/src/components/education/CourseLearningView.tsx +++ b/apps/web/src/components/education/CourseLearningView.tsx @@ -1,353 +1,8 @@ -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 '../../components/feedback/ToastProvider'; -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' && ( -
-