diff --git a/StartPlan.tsx b/StartPlan.tsx index 94fef5b..88a1cbe 100644 --- a/StartPlan.tsx +++ b/StartPlan.tsx @@ -31,7 +31,7 @@ export default function StartPlan() { const [reps, setReps] = useState(params.first?.reps.toString() || "0"); const [weight, setWeight] = useState(params.first?.weight.toString() || "0"); const [unit, setUnit] = useState(params.first?.unit || "kg"); - const [selected, setSelected] = useState(0); + const [selected, setSelected] = useState(null); const [settings, setSettings] = useState(); const [counts, setCounts] = useState(); const weightRef = useRef(null); @@ -88,6 +88,10 @@ export default function StartPlan() { useCallback(() => { settingsRepo.findOne({ where: {} }).then(setSettings); refresh(); + setRepo.find({ order: { created: "DESC" }, take: 1 }).then(sets => { + const index = exercises.findIndex(exercise => exercise === sets[0].name); + setSelected(index === -1 ? 0 : index); + }); // eslint-disable-next-line }, []) );