Where the three features surface:
· Routine editor — a progression rule for the whole routine, and per exercise a
Reps/Time switch, an optional rule of its own and the step it moves in.
· Workout — timed sets get a start button and the work-timer bar; every exercise says in
one line why its target is what it is ("every rep last time — 2.5 kg more", "missed
reps 3 sessions running — reset to 55 kg"). The weights are already right when the
session opens rather than being suggested afterwards, which is what the old bump-hint
button did.
· Stats — the exercise curve switches between top set and estimated 1RM, and names the
set the estimate came from. Timed exercises chart the longest hold.
· Exercise detail — an estimated 1RM from your log plus a calculator for a set you have
not done yet, so the number is reachable before there is any history.
· Finish summary — a new best estimated 1RM is reported separately from a weight PR.
Same weight for more reps is progress, but it is not a heavier lift.
Saving an exercise now replaces its config rather than merging into it, so switching back
from time to reps cannot leave a stale duration behind.
This commit is contained in:
1 parent
8e1d3b96a6
commit
c248ca3bae
5 files changed
+256
-54
No files matched your search
@@ -1,15 +1,16 @@
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
import { useEffect } from 'react'
|
||||
import { useStore } from '../store/useStore.js'
|
||||
import { exOr, isCardio } from '../lib/exercises.js'
|
||||
import { fmtNum, uid } from '../lib/format.js'
|
||||
import { exOr } from '../lib/exercises.js'
|
||||
import { uid } from '../lib/format.js'
|
||||
import { t } from '../lib/i18n.js'
|
||||
import { supersetUnits, cleanupSg } from '../lib/history.js'
|
||||
import { supersetUnits, cleanupSg, exLine } from '../lib/history.js'
|
||||
import { Thumb } from '../components/Media.jsx'
|
||||
import { glyphPicker, exercisePicker, exConfigSheet, confirmSheet } from '../sheets.jsx'
|
||||
import Icon from '../components/Icon.jsx'
|
||||
import { glyphOf } from '../lib/glyphs.js'
|
||||
import { Button } from '../components/ui.jsx'
|
||||
import { Button, SelectRow } from '../components/ui.jsx'
|
||||
import { POLICIES_FOR, POLICY_NAME, POLICY_DESC } from '../lib/progression.js'
|
||||
import BodyMap from '../components/BodyMap.jsx'
|
||||
import { loadOfRoutine, rankOf, MUSCLE_NAME } from '../lib/muscles.js'
|
||||
|
||||
@@ -46,6 +47,15 @@ export default function RoutineEdit() {
|
||||
<button className="iconbtn" aria-label={t('Pick an icon')} onClick={() => glyphPicker(r.emoji, g => update(s => { s.routines.find(x => x.id === id).emoji = g }))}><Icon name={glyphOf(r.emoji)} /></button>
|
||||
</div>
|
||||
|
||||
<div className="sect-b" style={{ marginBottom: 16 }}>
|
||||
<SelectRow icon="chartLine" title={t('Progression')} sheetTitle={t('Progression')}
|
||||
value={r.prog || 'linear'} onChange={v => update(s => { s.routines.find(x => x.id === id).prog = v })}
|
||||
options={POLICIES_FOR.reps.map(p => ({ value: p, label: t(POLICY_NAME[p]), subtitle: t(POLICY_DESC[p]) }))} />
|
||||
</div>
|
||||
<div className="small dim" style={{ margin: '-10px 2px 16px' }}>
|
||||
{t('Applies to every exercise in this routine that does not set its own rule.')}
|
||||
</div>
|
||||
|
||||
{r.ex.length ? <div className="list">{r.ex.map((e, i) => {
|
||||
// An unresolvable id is shown rather than skipped — hiding it left an entry you
|
||||
// could neither see nor delete, but that still turned up in the workout.
|
||||
@@ -54,10 +64,10 @@ export default function RoutineEdit() {
|
||||
return <div key={i}>
|
||||
{unitFirst.has(i) && <div className="ss-label"><Icon name="link" />{t('Superset')}</div>}
|
||||
<div className={'item' + (inSS.has(i) ? ' in-ss' : '')} onClick={() => {
|
||||
exConfigSheet(ex, e, cfg => edit(x => { Object.assign(x[i], cfg) }), () => edit(x => { x.splice(i, 1); cleanupSg(x) }))
|
||||
exConfigSheet(ex, e, cfg => edit(x => { x[i] = { id: x[i].id, sg: x[i].sg, ...cfg } }), () => edit(x => { x.splice(i, 1); cleanupSg(x) }), r)
|
||||
}}>
|
||||
<Thumb ex={ex} />
|
||||
<div className="grow"><div className="tt capitalize">{ex.n}</div><div className="ss">{isCardio(e.id) ? `${e.sets} × ${e.min || 20} min @ ${fmtNum(e.speed || 8)} km/h` : `${e.sets} × ${e.reps}${e.weight ? ' · ' + fmtNum(e.weight) + ' ' + S.unit : ''}`}</div></div>
|
||||
<div className="grow"><div className="tt capitalize">{ex.n}</div><div className="ss">{exLine(e, S.unit)}</div></div>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 2, flex: 'none', alignItems: 'center' }}>
|
||||
{i > 0 && <button className={'iconbtn' + (linkedPrev ? ' on-ss' : '')} title={t('Superset with exercise above')} style={{ width: 32, height: 28, borderRadius: 8, fontSize: 15 }} onClick={ev => { ev.stopPropagation(); toggleLink(i) }}><Icon name="link" /></button>}
|
||||
<div style={{ display: 'flex', gap: 2 }}>
|
||||
@@ -84,7 +94,7 @@ export default function RoutineEdit() {
|
||||
})()}
|
||||
|
||||
<div className="small dim row" style={{ margin: '10px 2px', gap: 5 }}><Icon name="link" style={{ fontSize: 13 }} />{t('Tap the link button on an exercise to superset it with the one above — you’ll do them back-to-back.')}</div>
|
||||
<Button variant="primary" onClick={() => exercisePicker(ex => exConfigSheet(ex, null, cfg => edit(x => { x.push({ id: ex.id, ...cfg }) })))} icon="plus">{t('Add exercise')}</Button>
|
||||
<Button variant="primary" onClick={() => exercisePicker(ex => exConfigSheet(ex, null, cfg => edit(x => { x.push({ id: ex.id, ...cfg }) }), null, r))} icon="plus">{t('Add exercise')}</Button>
|
||||
<div style={{ height: 10 }} />
|
||||
<Button variant="danger" onClick={() => confirmSheet({
|
||||
title: t('Delete routine?'), message: t('“{0}” and its exercises will be removed.', r.name), confirmText: t('Delete'), danger: true,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { useStore } from '../store/useStore.js'
|
||||
import { EXIDX, isCardio } from '../lib/exercises.js'
|
||||
import { bestWeightFor, lastBW, streakWeeks, setLabel } from '../lib/history.js'
|
||||
import { EXIDX } from '../lib/exercises.js'
|
||||
import { lastBW, streakWeeks, setLabel, modeOf } from '../lib/history.js'
|
||||
import { fmtNum, fmtDate, fmtVol, todayISO, weekKey } from '../lib/format.js'
|
||||
import { t } from '../lib/i18n.js'
|
||||
import { bwSheet, goalSheet, calendarSheet, workoutDetailSheet, WorkoutRow, bwDeltaColor } from '../sheets.jsx'
|
||||
@@ -11,6 +11,7 @@ import Heatmap from '../components/Heatmap.jsx'
|
||||
import Icon from '../components/Icon.jsx'
|
||||
import BodyMap, { BodyMapLegend } from '../components/BodyMap.jsx'
|
||||
import { loadOfWorkouts, rankOf, MUSCLE_NAME } from '../lib/muscles.js'
|
||||
import { e1rmSeries, best1RM } from '../lib/onerm.js'
|
||||
import { Button, Segmented, SelectRow } from '../components/ui.jsx'
|
||||
|
||||
// Which muscles the training in a window actually hit — and, the point of the card,
|
||||
@@ -62,6 +63,7 @@ export default function Stats() {
|
||||
const S = useStore(s => s.S)
|
||||
const [range, setRange] = useState(90)
|
||||
const [exId, setExId] = useState(null)
|
||||
const [exMetric, setExMetric] = useState('top')
|
||||
const now = Date.now()
|
||||
|
||||
const bwPts = S.bodyweight.filter(b => range === 0 || (b.t || new Date(b.d).getTime()) > now - range * 86400000)
|
||||
@@ -72,17 +74,34 @@ export default function Stats() {
|
||||
|
||||
const exHist = [...new Set(S.workouts.flatMap(w => w.entries.map(e => e.id)))].filter(id => EXIDX[id]).sort((a, b) => EXIDX[a].n < EXIDX[b].n ? -1 : 1)
|
||||
const curEx = exId && exHist.includes(exId) ? exId : exHist[0] || null
|
||||
const curCardio = curEx && isCardio(curEx)
|
||||
const metric = s => curCardio ? (s.speed || 0) : (s.w || 0)
|
||||
const exUnit = curCardio ? 'km/h' : S.unit
|
||||
// How this exercise was logged most recently decides what the curve means: top weight,
|
||||
// longest hold or top speed. Sets logged in another mode lack the field and score 0, so a
|
||||
// switched exercise drops its old points instead of mixing seconds into a weight chart.
|
||||
const curMode = curEx ? (() => {
|
||||
for (let i = S.workouts.length - 1; i >= 0; i--) {
|
||||
const en = S.workouts[i].entries.find(e => e.id === curEx)
|
||||
if (en) return modeOf({ ...(en.target || {}), id: curEx })
|
||||
}
|
||||
return modeOf({ id: curEx })
|
||||
})() : 'reps'
|
||||
const curCardio = curMode === 'cardio'
|
||||
const curTimed = curMode === 'time'
|
||||
const metric = s => curCardio ? (s.speed || 0) : curTimed ? (s.sec || 0) : (s.w || 0)
|
||||
const exUnit = curCardio ? 'km/h' : curTimed ? 's' : S.unit
|
||||
let exPts = [], exList = [], exBest = 0
|
||||
if (curEx) {
|
||||
S.workouts.forEach(w => {
|
||||
const en = w.entries.find(e => e.id === curEx)
|
||||
if (en) { const mx = Math.max(0, ...en.sets.filter(s => s.done).map(metric), curCardio ? 0 : (en.topW || 0)); if (mx > 0) { exPts.push({ t: w.start, y: mx, d: w.d, sets: en.sets.filter(s => s.done) }); if (mx > exBest) exBest = mx } }
|
||||
if (en) { const mx = Math.max(0, ...en.sets.filter(s => s.done).map(metric), curCardio || curTimed ? 0 : (en.topW || 0)); if (mx > 0) { exPts.push({ t: w.start, y: mx, d: w.d, sets: en.sets.filter(s => s.done), target: en.target }); if (mx > exBest) exBest = mx } }
|
||||
})
|
||||
exList = exPts.slice(-5).reverse()
|
||||
}
|
||||
// Estimated 1RM (issue #18) — only reps-mode training produces one, so cardio and timed
|
||||
// work simply have no points and the toggle stays hidden.
|
||||
const e1Pts = curEx ? e1rmSeries(S, curEx) : []
|
||||
const e1Best = curEx ? best1RM(S, curEx) : null
|
||||
const showE1 = e1Pts.length > 0
|
||||
const onE1 = showE1 && exMetric === 'e1rm'
|
||||
|
||||
return <>
|
||||
<div className="hdr"><div><h1>{t('Stats')}</h1><div className="sub">{t('Progress & history')}</div></div>
|
||||
@@ -123,10 +142,18 @@ export default function Stats() {
|
||||
<SelectRow title={t('Exercise')} sheetTitle={t('Exercise progress')} value={curEx} onChange={setExId}
|
||||
options={exHist.map(id => ({ value: id, label: EXIDX[id].n }))} />
|
||||
</div>
|
||||
<div className="chart"><LineChart points={exPts.map(p => ({ t: p.t, y: p.y, d: p.d }))} h={150} unit={exUnit} color="var(--blue)" /></div>
|
||||
{showE1 && <Segmented className="seg-range" value={exMetric} onChange={setExMetric}
|
||||
options={[{ value: 'top', label: t('Top set') }, { value: 'e1rm', label: t('Est. 1RM') }]} />}
|
||||
<div className="chart"><LineChart points={(onE1 ? e1Pts : exPts).map(p => ({ t: p.t, y: p.y, d: p.d }))} h={150} unit={exUnit} color="var(--blue)" /></div>
|
||||
<div style={{ marginTop: 8 }}>{exList.map((p, i) => <div key={i} className="row between small" style={{ padding: '6px 0', borderBottom: 'var(--hair) solid var(--sep)' }}>
|
||||
<span className="muted">{fmtDate(p.d, true)}</span><span>{p.sets.map(s => setLabel(curEx, s)).join(' ')}</span></div>)}</div>
|
||||
<div className="small dim" style={{ marginTop: 8 }}>{curCardio ? t('Top speed per workout') : t('Best set weight per workout')} · {t('Best:')} <b className="accent">{fmtNum(exBest)} {exUnit}</b></div>
|
||||
<span className="muted">{fmtDate(p.d, true)}</span><span>{p.sets.map(s => setLabel(curEx, s, p.target)).join(' ')}</span></div>)}</div>
|
||||
<div className="small dim" style={{ marginTop: 8 }}>
|
||||
{onE1 ? t('Estimated 1RM per workout') : curCardio ? t('Top speed per workout') : curTimed ? t('Longest hold per workout') : t('Best set weight per workout')} · {t('Best:')}
|
||||
{' '}<b className="accent">{fmtNum(onE1 ? e1Best.est : exBest)} {onE1 ? S.unit : exUnit}</b>
|
||||
</div>
|
||||
{showE1 && <div className="small dim" style={{ marginTop: 4 }}>
|
||||
{t('Best estimate from {0} on {1} — an estimate, not a tested max.', fmtNum(e1Best.w) + ' ' + S.unit + ' × ' + e1Best.r, fmtDate(e1Best.d, true))}
|
||||
</div>}
|
||||
</> : <div className="muted small">{t('Finish your first workout to see progress curves here.')}</div>}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,8 +2,8 @@ import { useEffect, useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { useStore } from '../store/useStore.js'
|
||||
import { useUI } from '../store/useUI.js'
|
||||
import { exOr, isCardio } from '../lib/exercises.js'
|
||||
import { effectiveRoutine, lastEntryFor, bestWeightFor, buildSets, setsDoneActive, supersetUnits, unitOf, setLabel } from '../lib/history.js'
|
||||
import { exOr } from '../lib/exercises.js'
|
||||
import { effectiveRoutine, lastEntryFor, bestWeightFor, buildSets, setsDoneActive, supersetUnits, unitOf, setLabel, modeOf } from '../lib/history.js'
|
||||
import { fmtNum, fmtDate, todayISO, exCount, DAYN } from '../lib/format.js'
|
||||
import { beep, vibrate } from '../lib/sound.js'
|
||||
import { t } from '../lib/i18n.js'
|
||||
@@ -12,6 +12,7 @@ import Media from '../components/Media.jsx'
|
||||
import { startFlow, exercisePicker, exConfigSheet, exerciseDetailSheet, topWeightSheet, finishWorkout, workoutCompleteSheet, confirmSheet } from '../sheets.jsx'
|
||||
import Icon from '../components/Icon.jsx'
|
||||
import { Button, Check, NumberField } from '../components/ui.jsx'
|
||||
import { nextPrescription, applyPrescription } from '../lib/progression.js'
|
||||
import { glyphOf } from '../lib/glyphs.js'
|
||||
|
||||
/* ---------- start chooser (no active workout) ---------- */
|
||||
@@ -52,20 +53,28 @@ function Elapsed({ start }) {
|
||||
return <span>{t}</span>
|
||||
}
|
||||
|
||||
/* ---------- one exercise block (strength: weight×reps · cardio: duration+speed) ---------- */
|
||||
function ExerciseBlock({ entryIdx, compact, onToggle, onField, onBumpAll, onAddSet, onRemoveSet }) {
|
||||
/* ---------- one exercise block (reps: weight×reps · time: a held duration · cardio: duration+speed) ---------- */
|
||||
function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemoveSet, onStartTimed }) {
|
||||
const S = useStore(s => s.S)
|
||||
const working = useUI(s => s.work)
|
||||
const entry = S.active.entries[entryIdx]
|
||||
const ex = exOr(entry.id)
|
||||
const cardio = isCardio(ex)
|
||||
const mode = modeOf({ ...(entry.target || {}), id: entry.id })
|
||||
const cardio = mode === 'cardio'
|
||||
const timed = mode === 'time'
|
||||
const last = lastEntryFor(S, entry.id)
|
||||
// The same number the "confirm your working weight" sheet calls your best, so the two
|
||||
// never disagree inside one session: heaviest logged set, or the working weight you kept.
|
||||
const best = cardio ? 0 : Math.max(bestWeightFor(S, entry.id), (S.exWeights[entry.id] || {}).w || 0)
|
||||
const hint = !cardio && last && last.sets.length >= (entry.target.sets || 1) && last.sets.every(s => s.r >= entry.target.reps) && last.sets[0].w > 0
|
||||
? Math.max(...last.sets.map(s => s.w)) + 2.5 : null
|
||||
const col1 = cardio ? { f: 'min', step: 1, dec: false, hd: t('Duration (min)') } : { f: 'w', step: 2.5, dec: true, hd: t('Weight ({0})', S.unit) }
|
||||
const col2 = cardio ? { f: 'speed', step: 0.5, dec: true, hd: t('Speed (km/h)') } : { f: 'r', step: 1, dec: false, hd: t('Reps') }
|
||||
// What the progression policy decided for this session, and why (issue #17). Computed when
|
||||
// the session was built so the reason matches the numbers already in the rows.
|
||||
const plan = entry.plan
|
||||
const col1 = cardio ? { f: 'min', step: 1, dec: false, hd: t('Duration (min)') }
|
||||
: timed ? { f: 'sec', step: 5, dec: false, hd: t('Seconds') }
|
||||
: { f: 'w', step: 2.5, dec: true, hd: t('Weight ({0})', S.unit) }
|
||||
const col2 = cardio ? { f: 'speed', step: 0.5, dec: true, hd: t('Speed (km/h)') }
|
||||
: timed ? { f: 'w', step: 2.5, dec: true, hd: t('Weight ({0})', S.unit) }
|
||||
: { f: 'r', step: 1, dec: false, hd: t('Reps') }
|
||||
// Uses the shared stepper markup so a set row picks up the same control styling
|
||||
// as every other +/- field in the app.
|
||||
const cell = (s, i, col, cls) => (
|
||||
@@ -87,14 +96,21 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onBumpAll, onAddS
|
||||
{ex.eq && <span className="tag">{t(ex.eq)}</span>}
|
||||
{best > 0 && <span className="tag nocap">{t('Best:')} {fmtNum(best)} {S.unit}</span>}
|
||||
</div>
|
||||
{last && <div className="small dim" style={{ marginBottom: 4 }}>{t('Last time')} ({fmtDate(last.d)}): {last.sets.map(s => setLabel(entry.id, s)).join(', ')}</div>}
|
||||
{hint && <button className="tag acc nocap" style={{ border: 'none', textAlign: 'left' }} onClick={() => { onBumpAll('w', hint); useUI.getState().toast(t('Weights bumped to {0}', fmtNum(hint) + ' ' + S.unit)) }}><Icon name="lightbulb" />{t('Last time you hit all reps — try {0}', fmtNum(hint) + ' ' + S.unit)}</button>}
|
||||
{last && <div className="small dim" style={{ marginBottom: 4 }}>{t('Last time')} ({fmtDate(last.d)}): {last.sets.map(s => setLabel(entry.id, s, last.target)).join(', ')}</div>}
|
||||
{plan && plan.why && plan.kind !== 'off' && <div className={'progline' + (plan.kind === 'deload' ? ' warn' : '')}>
|
||||
<Icon name={plan.kind === 'up' ? 'arrowUp' : plan.kind === 'deload' ? 'arrowDown' : 'lightbulb'} />
|
||||
<span>{t(...plan.why)}</span>
|
||||
</div>}
|
||||
<div className="card" style={{ marginTop: 10, marginBottom: 0 }}>
|
||||
<div className="sethead"><span className="n-sp" /><span className="w-sp">{col1.hd}</span><span className="r-sp">{col2.hd}</span><span className="ck-sp" /></div>
|
||||
<div className="sethead"><span className="n-sp" /><span className="w-sp">{col1.hd}</span><span className="r-sp">{col2.hd}</span>{timed && <span className="ck-sp" />}<span className="ck-sp" /></div>
|
||||
{entry.sets.map((s, i) => <div key={i} className={'setrow' + (s.done ? ' done' : '')}>
|
||||
<div className="n">{i + 1}</div>
|
||||
{cell(s, i, col1, 'w')}
|
||||
{cell(s, i, col2, 'r')}
|
||||
{/* A timed set is started, not typed: the timer counts the hold down and checks the
|
||||
set off itself. The checkbox stays for anyone who timed it on their own watch. */}
|
||||
{timed && <button className="setgo" aria-label={t('Start set')} disabled={s.done || !!working}
|
||||
onClick={() => onStartTimed(i)}><Icon name="play" /></button>}
|
||||
<Check checked={s.done} onChange={() => onToggle(i)} />
|
||||
</div>)}
|
||||
<div style={{ height: 8 }} />
|
||||
@@ -124,16 +140,31 @@ function ActiveWorkout() {
|
||||
|
||||
const mutEntry = (idx, fn) => update(s => { fn(s.active.entries[idx]) }, true)
|
||||
const setField = (idx, i, field, v) => mutEntry(idx, e => { e.sets[i][field] = v })
|
||||
const bumpAll = (idx, field, v) => mutEntry(idx, e => e.sets.forEach(s => { if (!s.done) s[field] = v }))
|
||||
const modeAt = idx => modeOf({ ...(A.entries[idx].target || {}), id: A.entries[idx].id })
|
||||
const addSet = idx => mutEntry(idx, e => {
|
||||
const l = e.sets[e.sets.length - 1]
|
||||
if (isCardio(e.id)) e.sets.push({ min: l ? l.min : (e.target.min || 20), speed: l ? l.speed : (e.target.speed || 8), done: false })
|
||||
const m = modeOf({ ...(e.target || {}), id: e.id })
|
||||
if (m === 'cardio') e.sets.push({ min: l ? l.min : (e.target.min || 20), speed: l ? l.speed : (e.target.speed || 8), done: false })
|
||||
else if (m === 'time') e.sets.push({ sec: l ? l.sec : (e.target.sec || 45), w: l ? (l.w || 0) : (e.target.weight || 0), done: false })
|
||||
else e.sets.push({ w: l ? l.w : 0, r: l ? l.r : e.target.reps, done: false })
|
||||
})
|
||||
const removeSet = idx => mutEntry(idx, e => { if (e.sets.length > 1) e.sets.pop() })
|
||||
|
||||
// A timed set is held, not typed. The work timer records what was actually held — an early
|
||||
// finish logs 0:38 of a 0:45 target rather than crediting the full prescription — and then
|
||||
// checks the set off through the normal path, so rest, supersets and the finish prompt all
|
||||
// behave exactly as they do for a reps set.
|
||||
const startTimed = (idx, i) => {
|
||||
const e = A.entries[idx]
|
||||
useUI.getState().startWork(e.sets[i].sec || 45, exOr(e.id).n, elapsed => {
|
||||
mutEntry(idx, en => { en.sets[i].sec = elapsed })
|
||||
if (!useStore.getState().S.active.entries[idx].sets[i].done) toggle(idx, i)
|
||||
})
|
||||
}
|
||||
|
||||
const toggle = (idx, i) => {
|
||||
const cardioEntry = isCardio(A.entries[idx].id)
|
||||
const m = modeAt(idx)
|
||||
const cardioEntry = m === 'cardio'
|
||||
const isLastUnit = unitIdx >= units.length - 1
|
||||
let askTop = false, exJustDone = false, workoutDone = false
|
||||
mutEntry(idx, e => {
|
||||
@@ -145,14 +176,17 @@ function ActiveWorkout() {
|
||||
if (isLastExInUnit && !unitDone) startRest(S.restSec)
|
||||
else if (unitDone) stopRest()
|
||||
if (unitDone && isLastUnit) workoutDone = true // last exercise's last set → done
|
||||
if (e.sets.every(x => x.done)) { exJustDone = true; if (!cardioEntry && !e.asked) { e.asked = true; askTop = true } }
|
||||
// Only reps training has a "working weight" worth confirming — a bodyweight plank
|
||||
// has nothing to put in that slider.
|
||||
if (e.sets.every(x => x.done)) { exJustDone = true; if (m === 'reps' && !e.asked) { e.asked = true; askTop = true } }
|
||||
}
|
||||
})
|
||||
// non-cardio: topWeight first (it chains into the finish/continue prompt on the last unit).
|
||||
// cardio or already-confirmed: go straight to the prompt.
|
||||
// reps: topWeight first (it chains into the finish/continue prompt on the last unit).
|
||||
// cardio/timed or already-confirmed: go straight to the prompt.
|
||||
if (askTop) topWeightSheet(idx)
|
||||
else if (workoutDone) workoutCompleteSheet()
|
||||
else if (exJustDone && cardioEntry) useUI.getState().toast(t('Cardio logged'))
|
||||
else if (exJustDone && m === 'time') useUI.getState().toast(t('Hold logged'))
|
||||
}
|
||||
|
||||
// Live-presence heartbeat so the admin dashboard can show who's training now. Signed-in only —
|
||||
@@ -198,11 +232,11 @@ function ActiveWorkout() {
|
||||
{unit.map((idx, k) => <div key={idx} className="ss-ex">
|
||||
{k > 0 && <div className="ss-amp">+</div>}
|
||||
<ExerciseBlock entryIdx={idx} compact
|
||||
onToggle={i => toggle(idx, i)} onField={(i, f, v) => setField(idx, i, f, v)} onBumpAll={(f, v) => bumpAll(idx, f, v)} onAddSet={() => addSet(idx)} onRemoveSet={() => removeSet(idx)} />
|
||||
onToggle={i => toggle(idx, i)} onField={(i, f, v) => setField(idx, i, f, v)} onAddSet={() => addSet(idx)} onRemoveSet={() => removeSet(idx)} onStartTimed={i => startTimed(idx, i)} />
|
||||
</div>)}
|
||||
</div>
|
||||
) : (
|
||||
<ExerciseBlock entryIdx={cur} onToggle={i => toggle(cur, i)} onField={(i, f, v) => setField(cur, i, f, v)} onBumpAll={(f, v) => bumpAll(cur, f, v)} onAddSet={() => addSet(cur)} onRemoveSet={() => removeSet(cur)} />
|
||||
<ExerciseBlock entryIdx={cur} onToggle={i => toggle(cur, i)} onField={(i, f, v) => setField(cur, i, f, v)} onAddSet={() => addSet(cur)} onRemoveSet={() => removeSet(cur)} onStartTimed={i => startTimed(cur, i)} />
|
||||
)}
|
||||
</> : <div className="empty"><div className="ico"><Icon name="shuffle" /></div>{t('Freestyle workout — add your first exercise.')}</div>}
|
||||
|
||||
@@ -213,9 +247,11 @@ function ActiveWorkout() {
|
||||
</div>
|
||||
<div style={{ height: 10 }} />
|
||||
<Button onClick={() => exercisePicker(ex => exConfigSheet(ex, null, cfg => update(s => {
|
||||
s.active.entries.push({ id: ex.id, target: { ...cfg }, sets: buildSets(s, { ...cfg, id: ex.id }) })
|
||||
const full = { ...cfg, id: ex.id }
|
||||
const plan = nextPrescription(s, full, s.routines.find(r => r.id === s.active.routineId))
|
||||
s.active.entries.push({ id: ex.id, target: { ...cfg }, plan, sets: applyPrescription(buildSets(s, full), plan) })
|
||||
s.active.cur = s.active.entries.length - 1
|
||||
})))} icon="plus">{t('Add exercise')}</Button>
|
||||
}), null, S.routines.find(r => r.id === A.routineId)))} icon="plus">{t('Add exercise')}</Button>
|
||||
<div style={{ height: 10 }} />
|
||||
{(() => {
|
||||
const exDone = A.entries.filter(e => e.sets.length && e.sets.every(s => s.done)).length
|
||||
|
||||
Reference in new issue
Block a user