diff --git a/src/components/App.tsx b/src/components/App.tsx index feaf556..c826382 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -6,6 +6,12 @@ import '../assets/WestwoodSans-Regular.ttf'; function App(): JSX.Element { const [exerciseCount, setExerciseCount] = useState(0); + // const [completeExercises, setCompleteExercises] = useState(0); + + const updateLevel = (newLevel: number): void => { + setExerciseCount(newLevel - 1); + }; + if (exerciseCount == 5) { return (
@@ -16,8 +22,9 @@ function App(): JSX.Element { return (
- + setExerciseCount(exerciseCount + 1)} />
diff --git a/src/components/shared/ExerciseSide.tsx b/src/components/shared/ExerciseSide.tsx index 600089c..c8a80cb 100644 --- a/src/components/shared/ExerciseSide.tsx +++ b/src/components/shared/ExerciseSide.tsx @@ -13,10 +13,14 @@ import UnitCircleInput from './Exercises/UnitCircleInput'; ('./Exercises/AxisExercise'); interface ExerciseSideProps { + ExercisesNum: number; incrementExercise: () => void; } -function ExerciseSide({ incrementExercise }: ExerciseSideProps): JSX.Element { +function ExerciseSide({ + incrementExercise, + ExercisesNum, +}: ExerciseSideProps): JSX.Element { const [completeExercises, setCompleteExercises] = useState(0); type availableExercises = 'axis' | 'congrats' | 'graph' | 'unitcircle'; @@ -28,6 +32,10 @@ function ExerciseSide({ incrementExercise }: ExerciseSideProps): JSX.Element { ]; let curExercise; + if (completeExercises != ExercisesNum) { + setCompleteExercises(ExercisesNum); + } + if (exercises[completeExercises] == 'graph') { curExercise = (
diff --git a/src/components/shared/LessonSide/LessonSide.tsx b/src/components/shared/LessonSide/LessonSide.tsx index 59dcc91..d598084 100644 --- a/src/components/shared/LessonSide/LessonSide.tsx +++ b/src/components/shared/LessonSide/LessonSide.tsx @@ -8,9 +8,10 @@ import Turtle from './Turtle'; interface lessonSideProps { levelNum: number; + updateLevel: (newCount: number) => void; } -function LessonSide({ levelNum }: lessonSideProps): JSX.Element { +function LessonSide({ levelNum, updateLevel }: lessonSideProps): JSX.Element { const lesson_info = LessonSideContent[levelNum] || []; return (
@@ -33,6 +34,7 @@ function LessonSide({ levelNum }: lessonSideProps): JSX.Element { numLevels={6} currentLevel={levelNum} maxLevelReached={6} + updateLevel={updateLevel} />