diff --git a/components/Tracker.tsx b/components/Tracker.tsx index da3238c..17db065 100644 --- a/components/Tracker.tsx +++ b/components/Tracker.tsx @@ -69,6 +69,7 @@ const Tracker: React.FC = ({ userId, userWeight, activeSession, ac useEffect(() => { const loadData = async () => { const exList = await getExercises(userId); + exList.sort((a, b) => a.name.localeCompare(b.name)); setExercises(exList); const planList = await getPlans(userId); setPlans(planList); @@ -253,8 +254,7 @@ const Tracker: React.FC = ({ userId, userWeight, activeSession, ac const handleCreateExercise = async (newEx: ExerciseDef) => { await saveExercise(userId, newEx); - const exList = await getExercises(userId); - setExercises(exList.filter(e => !e.isArchived)); + setExercises(prev => [...prev, newEx].sort((a, b) => a.name.localeCompare(b.name))); setSelectedExercise(newEx); setIsCreating(false); }; @@ -493,8 +493,6 @@ const Tracker: React.FC = ({ userId, userWeight, activeSession, ac > {exercises - .slice() - .sort((a, b) => a.name.localeCompare(b.name)) .map(ex => ( ))} @@ -710,6 +708,7 @@ const Tracker: React.FC = ({ userId, userWeight, activeSession, ac onClose={() => setIsCreating(false)} onSave={handleCreateExercise} lang={lang} + existingExercises={exercises} /> )}