diff --git a/frontend/src/pages/Lesson.tsx b/frontend/src/pages/Lesson.tsx index d830698..225a8c4 100644 --- a/frontend/src/pages/Lesson.tsx +++ b/frontend/src/pages/Lesson.tsx @@ -1,21 +1,41 @@ import { useLocation, useNavigate } from 'react-router-dom'; -import { Icon } from '@iconify/react'; import { useState } from 'react'; import WrittenQuestionExercise from "../components/WrittenQuestionExercise" +import Progress from '../components/Progress'; export default function Course() { const location = useLocation(); const navigate = useNavigate(); const { questions } = location.state; - const [currQuestion, setCurrQuestion] = useState(0); + const [currQuestion, setCurrQuestion] = useState(0); - const renderLessonContent = () => { + const handleNavigateBack = () => { + navigate(-1); + }; + + const handleQuestionSubmit = () => { + if (currQuestion < questions.length - 1) { + setCurrQuestion(currQuestion + 1); + } else { + navigate("/review"); + } + } + + const renderQuestion = (questionIndex: number) => { const {question, wordBank, expected, type, exercise} = questions[currQuestion]; switch (type) { case 'written': switch (exercise) { case 'questions': - return ; + return ; // case 'vocabulary': // return ; default: @@ -37,10 +57,10 @@ export default function Course() { return (
- navigate(-1)} /> +

Course Page

- {renderLessonContent()} + {renderQuestion(currQuestion)}
)