diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx index 94d7be9..f59ca7a 100644 --- a/frontend/src/views/Workout.jsx +++ b/frontend/src/views/Workout.jsx @@ -218,6 +218,43 @@ function ActiveWorkout() { const onPairPrev = !isSuperset && cur > 0 ? () => pairAt(cur - 1, cur) : null const onPairNext = !isSuperset && cur < A.entries.length - 1 ? () => pairAt(cur, cur + 1) : null + // Remove a whole exercise from the session. The confirmation always asks first; in a + // superset it asks WHICH exercise of the group to remove. + const removeExercise = idx => update(s => { + if (!s.active || !Array.isArray(s.active.entries)) return + if (idx < 0 || idx >= s.active.entries.length) return + s.active.entries.splice(idx, 1) + if (s.active.cur >= s.active.entries.length) s.active.cur = Math.max(0, s.active.entries.length - 1) + }, true) + const confirmRemoveExercise = idx => { + const e = A.entries[idx] + if (!e) return + const hasDone = (e.sets || []).some(s => s.done) + confirmSheet({ + title: t('Remove {0}?', exOr(e.id).n), + message: hasDone + ? t('The sets you logged for this exercise in this session will be lost.') + : t('This removes the exercise from your current session.'), + confirmText: t('Remove'), danger: true, onConfirm: () => removeExercise(idx) + }) + } + const removeExerciseSheet = () => { + if (unit.length > 1) { + useUI.getState().openSheet(close => ( +