From 6e473a981530375d5d5bc5ea4cbbe0c4e93d9743 Mon Sep 17 00:00:00 2001 From: Duarte Santos Date: Mon, 20 Jul 2026 20:33:05 +0200 Subject: [PATCH] =?UTF-8?q?Arbeitsgewicht-Abfrage=20mit=20Slider,=20eigene?= =?UTF-8?q?=20Best=C3=A4tigungs-Dialoge,=20Gewichts-History=20nur=20letzte?= =?UTF-8?q?=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Die 'Arbeitsgewicht bestätigen'-Abfrage im Workout nutzt jetzt denselben Slider + Plus/Minus (geteilte WeightInput-Komponente) - Alle window.confirm-Systemdialoge durch eigene, app-farbige Center-Dialoge ersetzt (confirmSheet): Workout verwerfen/vorzeitig beenden, Routine/Workout löschen, Abmelden, Reset, Backup importieren - Log-Sheet zeigt nur noch die letzten 3 Gewichts-Einträge --- frontend/src/sheets.jsx | 41 ++++++++++++++++++++++-------- frontend/src/views/RoutineEdit.jsx | 22 ++++++++-------- frontend/src/views/Settings.jsx | 9 +++---- frontend/src/views/Workout.jsx | 4 +-- 4 files changed, 48 insertions(+), 28 deletions(-) diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsx index 660850a..90903e3 100644 --- a/frontend/src/sheets.jsx +++ b/frontend/src/sheets.jsx @@ -15,6 +15,21 @@ const ui = () => useUI.getState() const toast = m => ui().toast(m) const snd = () => S().sound +/* ============================ custom confirm dialog ============================ */ +function ConfirmDialog({ title, message, confirmText, cancelText, danger, onConfirm, close }) { + return
+ {title &&

{title}

} +
{message}
+ +
+ +
+} +// Themed replacement for window.confirm — callback-based (no blocking). +export function confirmSheet(opts) { + ui().openSheet(close => , { kind: 'center' }) +} + /* ============================ starter plan ============================ */ export function loadStarterPlan() { const mk = (name, emoji, list) => ({ id: uid(), name, emoji, ex: list.map(([id, sets, reps]) => ({ id, sets, reps, weight: 0 })) }) @@ -66,7 +81,7 @@ function BwSheet({ required, onDone, close }) { close() if (onDone) onDone(n); else toast('Weight saved ✓') } - const recent = [...st.bodyweight].reverse().slice(0, 6) + const recent = [...st.bodyweight].reverse().slice(0, 3) const delEntry = d => update(s => { s.bodyweight = s.bodyweight.filter(b => b.d !== d) }) return <>

{required ? 'Quick check-in ⚖️' : 'Log body weight'}

@@ -315,7 +330,7 @@ function WorkoutDetail({ w, close }) {
{e.sets.filter(s => s.done).map(s => setLabel(e.id, s)).join(' · ') || 'no sets'}
})} - + } export const workoutDetailSheet = w => ui().openSheet(close => ) @@ -396,9 +411,7 @@ function TopWeight({ entryIdx, close }) { const ex = EXIDX[entry.id] const maxSet = Math.max(0, ...entry.sets.filter(s => s.done).map(s => s.w || 0)) const prevBest = Math.max((st.exWeights[entry.id] || {}).w || 0, bestWeightFor(st, entry.id)) - const [v, setV] = useState(String(Math.max(maxSet, prevBest) || entry.target.weight || 0)) - const ref = useRef(null) - useEffect(() => { setTimeout(() => { ref.current?.focus(); ref.current?.select() }, 250) }, []) + const [v, setV] = useState(Math.max(maxSet, prevBest) || entry.target.weight || 0) const units = supersetUnits(A.entries) const unit = unitOf(units, entryIdx) @@ -407,7 +420,7 @@ function TopWeight({ entryIdx, close }) { const isLastUnit = unitIdx === units.length - 1 const commit = advance => { - const n = parseFloat(v) + const n = Math.round((v || 0) * 10) / 10 if (!isFinite(n) || n < 0) { toast('Enter a valid weight'); return } update(s => { s.active.entries[entryIdx].topW = n @@ -423,7 +436,8 @@ function TopWeight({ entryIdx, close }) { return <>

✅ {ex.n} done

Confirm the weight you worked with — your highest becomes the default next time.{!unitDone && unit.length > 1 ? ' Then finish the superset partner.' : ''}
-
setV(e.target.value)} />{st.unit}
+ +
{prevBest > 0 ?
Previous best: {fmtNum(prevBest)} {st.unit}{maxSet > prevBest && — new record! 🏆}
:
} {unitDone ? <> @@ -462,13 +476,18 @@ function FinishSummary({ w, prs, close }) {
} export function finishWorkout() { - const st = S() - const A = st.active + const A = S().active if (!A) return const done = setsDoneActive(A) const total = A.entries.reduce((n, e) => n + e.sets.length, 0) - if (!done && !confirm('No sets logged — finish anyway?')) return - if (done < total && done > 0 && !confirm('Some sets are unchecked. Finish workout?')) return + if (!done) { confirmSheet({ title: 'Nothing logged yet', message: 'You haven’t checked off any sets. Finish the workout anyway?', confirmText: 'Finish anyway', onConfirm: doFinishWorkout }); return } + if (done < total) { confirmSheet({ title: 'Finish early?', message: `${total - done} set${total - done === 1 ? '' : 's'} still unchecked. Finish the workout now?`, confirmText: 'Finish workout', onConfirm: doFinishWorkout }); return } + doFinishWorkout() +} +function doFinishWorkout() { + const st = S() + const A = st.active + if (!A) return const prs = [] A.entries.forEach(e => { const mx = Math.max(0, ...e.sets.filter(s => s.done).map(s => s.w)) diff --git a/frontend/src/views/RoutineEdit.jsx b/frontend/src/views/RoutineEdit.jsx index a8b2112..5e3b05c 100644 --- a/frontend/src/views/RoutineEdit.jsx +++ b/frontend/src/views/RoutineEdit.jsx @@ -5,7 +5,7 @@ import { EXIDX, isCardio } from '../lib/exercises.js' import { fmtNum, uid } from '../lib/format.js' import { supersetUnits } from '../lib/history.js' import { Thumb } from '../components/Media.jsx' -import { emojiPicker, exercisePicker, exConfigSheet } from '../sheets.jsx' +import { emojiPicker, exercisePicker, exConfigSheet, confirmSheet } from '../sheets.jsx' // drop superset ids that no longer have an adjacent partner (after unlink/reorder) function cleanupSg(ex) { @@ -71,14 +71,16 @@ export default function RoutineEdit() {
Tip: tap 🔗 on an exercise to superset it with the one above — you’ll do them back-to-back.
- +
} diff --git a/frontend/src/views/Settings.jsx b/frontend/src/views/Settings.jsx index 49d6cce..a3ea5e1 100644 --- a/frontend/src/views/Settings.jsx +++ b/frontend/src/views/Settings.jsx @@ -4,7 +4,7 @@ import { useStore, DEF, hasData } from '../store/useStore.js' import { useUI } from '../store/useUI.js' import { ACCENTS, todayISO } from '../lib/format.js' import { webauthnOK, passkeyLogin, passkeyRegister, IS_ANDROID } from '../lib/api.js' -import { loadStarterPlan } from '../sheets.jsx' +import { loadStarterPlan, confirmSheet } from '../sheets.jsx' export default function Settings() { const nav = useNavigate() @@ -26,8 +26,7 @@ export default function Settings() { try { const data = JSON.parse(rd.result) if (!data.workouts || !data.routines) throw new Error('not an openGym backup') - if (!confirm('Replace all current data with this backup?')) return - replaceState(Object.assign(JSON.parse(JSON.stringify(DEF)), data), true); toast('Backup imported ✓') + confirmSheet({ title: 'Import backup?', message: 'This replaces all current data with the backup file.', confirmText: 'Import', danger: true, onConfirm: () => { replaceState(Object.assign(JSON.parse(JSON.stringify(DEF)), data), true); toast('Backup imported ✓') } }) } catch (e) { toast('Import failed: ' + e.message) } } rd.readAsText(f) @@ -45,7 +44,7 @@ export default function Settings() {

Account

{user ?
{user.name}
Signed in with passkey — data syncs to this profile.
- +
: <>
Guest mode — data lives only in this browser. Create a passkey profile to keep it safe and separate per person.
{webauthnOK() ? <> @@ -89,7 +88,7 @@ export default function Settings() {
-
+

Tip

diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx index 9ca2565..fa9a457 100644 --- a/frontend/src/views/Workout.jsx +++ b/frontend/src/views/Workout.jsx @@ -7,7 +7,7 @@ import { effectiveRoutine, lastEntryFor, bestWeightFor, buildSets, setsDoneActiv import { fmtNum, fmtDate, todayISO, DAYN } from '../lib/format.js' import { beep, vibrate } from '../lib/sound.js' import Media from '../components/Media.jsx' -import { startFlow, exercisePicker, exConfigSheet, exerciseDetailSheet, topWeightSheet, finishWorkout, workoutCompleteSheet } from '../sheets.jsx' +import { startFlow, exercisePicker, exConfigSheet, exerciseDetailSheet, topWeightSheet, finishWorkout, workoutCompleteSheet, confirmSheet } from '../sheets.jsx' /* ---------- start chooser (no active workout) ---------- */ function StartChooser() { @@ -144,7 +144,7 @@ function ActiveWorkout() { return
- +
{A.name}
· {done}/{total} sets