Exercise archivation fixed

This commit is contained in:
AG
2025-11-25 23:32:47 +02:00
parent e3efc84250
commit 701d217c89
4 changed files with 21 additions and 13 deletions

View File

@@ -72,7 +72,9 @@ const Profile: React.FC<ProfileProps> = ({ user, onLogout, lang, onLanguageChang
};
const refreshExercises = async () => {
setExercises(await getExercises(user.id));
const exercises = await getExercises(user.id);
console.log('Refreshed exercises:', exercises);
setExercises(exercises);
};
// Snackbar State
@@ -160,10 +162,12 @@ const Profile: React.FC<ProfileProps> = ({ user, onLogout, lang, onLanguageChang
};
// Exercise Management Handlers
const handleArchiveExercise = (ex: ExerciseDef, archive: boolean) => {
const handleArchiveExercise = async (ex: ExerciseDef, archive: boolean) => {
const updated = { ...ex, isArchived: archive };
saveExercise(user.id, updated);
refreshExercises();
console.log('Archiving exercise:', updated);
await saveExercise(user.id, updated);
console.log('Archive complete, refreshing...');
await refreshExercises();
};
const handleSaveExerciseEdit = () => {

View File

@@ -108,14 +108,12 @@ const Tracker: React.FC<TrackerProps> = ({ userId, userWeight, activeSession, ac
if (step) {
const exDef = exercises.find(e => e.id === step.exerciseId);
if (exDef) {
if (!selectedExercise || selectedExercise.id !== exDef.id) {
setSelectedExercise(exDef);
}
setSelectedExercise(exDef);
}
}
}
}
}, [activeSession, activePlan, currentStepIndex, exercises, selectedExercise]);
}, [currentStepIndex, activePlan, exercises]);
useEffect(() => {
const updateSelection = async () => {