diff --git a/src/App.tsx b/src/App.tsx index a8d722d..9f8b1cb 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -4,14 +4,20 @@ import Header from "./components/Header"; import WorkoutSelector from "./components/WorkoutSelector"; import { CurrentExerciseType, ExerciseInfosType } from "./types"; -enum Stat { Reps, Sets, Weight, Time, Steps, MaxHR, AvgHR, StepsPerMin }; +export enum Stat { Reps, Sets, Weight, Time, Steps, MaxHR, AvgHR, StepsPerMin }; -function statLength() { +export function statLength() { return Object.keys(Stat).length / 2; } -const exerciseInfos: ExerciseInfosType = { - Squat: { +export const exerciseInfos: ExerciseInfosType = { + "Squat": { + defaultStats: [Stat.Reps, Stat.Sets, Stat.Weight] + }, + "Deadlift": { + defaultStats: [Stat.Reps, Stat.Sets, Stat.Weight] + }, + "Bench Press": { defaultStats: [Stat.Reps, Stat.Sets, Stat.Weight] } } @@ -44,9 +50,9 @@ function App() { const l = statLength(); for (let i = 0; i < l; i++) { if (currentExercises[addIndex].stats[Stat[i]] === undefined) { - currentExercises[addIndex].stats[Stat[i]] = null; - console.log(currentExercises); - setExercises(currentExercises); + var newExercises = [...currentExercises]; + newExercises[addIndex].stats[Stat[i]] = null; + setExercises(newExercises); return; } diff --git a/src/components/Exercise.tsx b/src/components/Exercise.tsx index 93b4172..64c6953 100644 --- a/src/components/Exercise.tsx +++ b/src/components/Exercise.tsx @@ -1,10 +1,13 @@ +import { exerciseInfos } from "../App"; import { CurrentExerciseType } from "../types"; import InputStat from "./InputStat"; function Exercise({ currentExercise, deleteCurrentExercise, addStat }: { currentExercise: CurrentExerciseType, deleteCurrentExercise: () => void, addStat: () => void }) { return (
- Exercise : + Exercise : {Object.entries(currentExercise.stats).map(([stat, value], index) => )} diff --git a/src/components/InputStat.tsx b/src/components/InputStat.tsx index 15fa920..892358e 100644 --- a/src/components/InputStat.tsx +++ b/src/components/InputStat.tsx @@ -1,7 +1,10 @@ +import { Stat, statLength } from "../App"; function InputStat({ stat, statType }: { stat: string, statType?: string }) { return (
- : + :
); }