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}
+
{ close(); onConfirm && onConfirm() }}>{confirmText || 'Confirm'}
+
+
{cancelText || 'Cancel'}
+
+}
+// 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'}
})}
- { if (confirm('Delete this workout from history?')) { update(s => { s.workouts = s.workouts.filter(x => x.id !== w.id) }); close(); toast('Workout deleted') } }}>Delete workout
+ confirmSheet({ title: 'Delete workout?', message: 'This removes it from your history for good.', confirmText: 'Delete', danger: true, onConfirm: () => { update(s => { s.workouts = s.workouts.filter(x => x.id !== w.id) }); close(); toast('Workout deleted') } })}>Delete workout
>
}
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 ? <>
commit(true)}>{isLastUnit ? 'Save ✓' : 'Save & next exercise ›'}
@@ -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.
exercisePicker(ex => exConfigSheet(ex, null, cfg => edit(x => { x.push({ id: ex.id, ...cfg }) })))}>+ Add exercise
- {
- if (!confirm('Delete "' + r.name + '"?')) return
- update(s => {
- s.routines = s.routines.filter(x => x.id !== id)
- Object.keys(s.week).forEach(k => { if (s.week[k] === id) delete s.week[k] })
- Object.keys(s.dayPlan).forEach(k => { if (s.dayPlan[k] === id) delete s.dayPlan[k] })
- })
- nav('/plan')
- }}>Delete routine
+ confirmSheet({
+ title: 'Delete routine?', message: `“${r.name}” and its exercises will be removed.`, confirmText: 'Delete', danger: true,
+ onConfirm: () => {
+ update(s => {
+ s.routines = s.routines.filter(x => x.id !== id)
+ Object.keys(s.week).forEach(k => { if (s.week[k] === id) delete s.week[k] })
+ Object.keys(s.dayPlan).forEach(k => { if (s.dayPlan[k] === id) delete s.dayPlan[k] })
+ })
+ nav('/plan')
+ }
+ })}>Delete routine
}
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.
-
{ if (confirm('Sign out? Local data is synced to your profile first, then cleared from this device.')) { signOut(); nav('/home') } }}>Sign out
+
confirmSheet({ title: 'Sign out?', message: 'Your data is synced to your profile first, then cleared from this device.', confirmText: 'Sign out', danger: true, onConfirm: () => { signOut(); nav('/home') } })}>Sign out
: <>
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() {
fileRef.current.click()}>⬆️ Import backup
Load starter plan (PPL)
-
{ if (confirm('Delete ALL data (plan, workouts, body weight)?') && confirm('Really sure? This cannot be undone.')) { replaceState(JSON.parse(JSON.stringify(DEF)), true); nav('/home'); toast('All data reset') } }}>Reset everything
+
confirmSheet({ title: 'Reset everything?', message: 'Deletes your plan, workouts and body weight on this device. This cannot be undone.', confirmText: 'Delete everything', danger: true, onConfirm: () => { replaceState(JSON.parse(JSON.stringify(DEF)), true); nav('/home'); toast('All data reset') } })}>Reset everything
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
-
{ if (confirm('Discard this workout? Logged sets will be lost.')) { update(s => { s.active = null }); stopRest(); nav('/home') } }}>✕
+
confirmSheet({ title: 'Discard workout?', message: 'The sets you logged in this session will be lost.', confirmText: 'Discard', danger: true, onConfirm: () => { update(s => { s.active = null }); stopRest(); nav('/home') } })}>✕
{A.name}
· {done}/{total} sets
✓