Exercise archivation fixed
This commit is contained in:
@@ -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 = () => {
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user