change
This commit is contained in:
parent
44d1ae5111
commit
d8b600a74e
30
src/App.tsx
30
src/App.tsx
@ -2,13 +2,22 @@ import { useState } from "react";
|
|||||||
import Exercises from "./components/Exercises";
|
import Exercises from "./components/Exercises";
|
||||||
import Header from "./components/Header";
|
import Header from "./components/Header";
|
||||||
import WorkoutSelector from "./components/WorkoutSelector";
|
import WorkoutSelector from "./components/WorkoutSelector";
|
||||||
import { CurrentExerciseType } from "./types";
|
import { CurrentExerciseType, ExerciseInfosType } from "./types";
|
||||||
|
|
||||||
|
|
||||||
enum Stat { Reps, Sets, Weight, Time, Steps, MaxHR, AvgHR, StepsPerMin };
|
enum Stat { Reps, Sets, Weight, Time, Steps, MaxHR, AvgHR, StepsPerMin };
|
||||||
|
|
||||||
|
function statLength() {
|
||||||
|
return Object.keys(Stat).length / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
const exerciseInfos: ExerciseInfosType = {
|
||||||
|
Squat: {
|
||||||
|
defaultStats: [Stat.Reps, Stat.Sets, Stat.Weight]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [currentExercises, setExercises]: [CurrentExerciseType[], any] = useState([
|
const [currentExercises, setExercises] = useState<CurrentExerciseType[]>([
|
||||||
{
|
{
|
||||||
name: "Squat",
|
name: "Squat",
|
||||||
stats: { "Weight": 10 }
|
stats: { "Weight": 10 }
|
||||||
@ -28,15 +37,20 @@ function App() {
|
|||||||
{
|
{
|
||||||
name: "Squat",
|
name: "Squat",
|
||||||
stats: {}
|
stats: {}
|
||||||
}])
|
}]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addStat(addIndex: number) {
|
function addStat(addIndex: number) {
|
||||||
for (const checkStat in Stat) {
|
const l = statLength();
|
||||||
//console.log(checkStat, typeof (checkStat));
|
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);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
console.log(currentExercises[addIndex].stats)
|
|
||||||
//setExercises([..])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
8
src/types.d.ts
vendored
8
src/types.d.ts
vendored
@ -1,4 +1,8 @@
|
|||||||
export type CurrentExerciseType = {
|
export type CurrentExerciseType = {
|
||||||
name: string,
|
name: string,
|
||||||
stats: { [stat: Stat]: any },
|
stats: { [stat: string]: any },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type ExerciseInfosType = {
|
||||||
|
[key: string]: { defaultStats: Stat[] }
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user