feat: expose the double progression rep range
This commit is contained in:
1 parent
cb24bf12d7
commit
c71cb09515
16 files changed
+98
-10
No files matched your search
+39
-8
@@ -20,6 +20,7 @@ import { parseImport, mergeImport } from './lib/import-csv.js'
|
||||
import { buildPlanBundle, parsePlan, mergePlan, printPlan } from './lib/plan-share.js'
|
||||
import { estimate1RM, best1RM, is1RMRecord, REP_CAP } from './lib/onerm.js'
|
||||
import { nextPrescription, applyPrescription, policyFor, defaultIncrement, POLICIES_FOR, POLICY_NAME, POLICY_DESC, MAX_BW_SETS } from './lib/progression.js'
|
||||
import { normalizeRepRange } from './lib/rep-range.js'
|
||||
import { MOBILE, shareExport } from './lib/mobile.js'
|
||||
import { buildCompletedWorkout } from './lib/finish-workout.js'
|
||||
import { isWarmupRow } from './lib/workout-model.js'
|
||||
@@ -564,10 +565,17 @@ function ProgressionFields({ ex, mode, c, setC, routine, unit }) {
|
||||
const inherited = policyFor({ id: ex.id }, routine, mode)
|
||||
const active = policyFor({ ...c, id: ex.id }, routine, mode)
|
||||
const inc = c.inc > 0 ? c.inc : (mode === 'time' ? 5 : defaultIncrement(ex.id, unit))
|
||||
const range = active === 'double' ? normalizeRepRange(c.reps, c.repsMin) : null
|
||||
const setRule = v => setC(x => {
|
||||
const next = { ...x, prog: v || undefined }
|
||||
return policyFor({ ...next, id: ex.id }, routine, mode) === 'double'
|
||||
? { ...next, ...normalizeRepRange(next.reps, next.repsMin) }
|
||||
: next
|
||||
})
|
||||
return <>
|
||||
<h4 className="sec">{t('Progression')}</h4>
|
||||
<div className="sect-b" style={{ marginBottom: 8 }}>
|
||||
<SelectRow title={t('Rule')} sheetTitle={t('Progression')} value={c.prog || ''} onChange={v => setC(x => ({ ...x, prog: v || undefined }))}
|
||||
<SelectRow title={t('Rule')} sheetTitle={t('Progression')} value={c.prog || ''} onChange={setRule}
|
||||
options={[{ value: '', label: t('Follow the routine ({0})', t(POLICY_NAME[inherited])) },
|
||||
...options.map(p => ({ value: p, label: t(POLICY_NAME[p]) }))]} />
|
||||
</div>
|
||||
@@ -575,8 +583,12 @@ function ProgressionFields({ ex, mode, c, setC, routine, unit }) {
|
||||
{active !== 'off' && <div className="row cfgrow" style={{ marginBottom: 18 }}>
|
||||
<Stepper label={mode === 'time' ? t('Step (seconds)') : t('Step ({0})', unit)} value={inc}
|
||||
step={mode === 'time' ? 5 : 1.25} decimal={mode !== 'time'} onChange={v => setC(x => ({ ...x, inc: v }))} />
|
||||
{active === 'double' && <Stepper label={t('Reps from')} value={c.repsMin || Math.max(1, (c.reps || 10) - 2)}
|
||||
step={1} decimal={false} onChange={v => setC(x => ({ ...x, repsMin: v }))} />}
|
||||
{active === 'double' && <>
|
||||
<Stepper label={t('Reps from')} value={range.repsMin} step={1} decimal={false}
|
||||
onChange={v => setC(x => ({ ...x, ...normalizeRepRange(x.reps, v) }))} />
|
||||
<Stepper label={t('Reps up to')} value={range.reps} step={1} decimal={false}
|
||||
onChange={v => setC(x => ({ ...x, ...normalizeRepRange(v, x.repsMin) }))} />
|
||||
</>}
|
||||
</div>}
|
||||
</>
|
||||
}
|
||||
@@ -584,15 +596,28 @@ function ProgressionFields({ ex, mode, c, setC, routine, unit }) {
|
||||
function ExConfig({ ex, existing, onSave, onDelete, close, routine, initial }) {
|
||||
const st = useStore(s => s.S)
|
||||
const cardio = isCardio(ex.id)
|
||||
const [c, setC] = useState(existing || initial || defaultConfig(ex.id))
|
||||
const seed = existing || initial || defaultConfig(ex.id)
|
||||
const [c, setC] = useState(() => {
|
||||
const cfg = { ...seed }
|
||||
return policyFor({ ...cfg, id: ex.id }, routine, modeOf({ ...cfg, id: ex.id })) === 'double'
|
||||
? { ...cfg, ...normalizeRepRange(cfg.reps, cfg.repsMin) }
|
||||
: cfg
|
||||
})
|
||||
// Cardio keeps its own duration+speed form; the reps/time choice (issue #16) is offered for
|
||||
// everything else, which is where the gap was — planks, hangs, wall sits, loaded carries.
|
||||
const mode = cardio ? 'cardio' : modeOf({ ...c, id: ex.id })
|
||||
// Both default from the dataset and are then whatever the config says — see isBw.
|
||||
const bw = !cardio && isBw({ ...c, id: ex.id })
|
||||
const perSide = isPerSide(c)
|
||||
const activePolicy = policyFor({ ...c, id: ex.id }, routine, mode)
|
||||
const double = mode === 'reps' && activePolicy === 'double'
|
||||
// Keep whatever the other mode already had (sets, weight) and fill only what is missing.
|
||||
const setMode = m => setC(x => ({ ...defaultConfig(ex.id, m), ...x, mode: m }))
|
||||
const setMode = m => setC(x => {
|
||||
const next = { ...defaultConfig(ex.id, m), ...x, mode: m }
|
||||
return m === 'reps' && policyFor({ ...next, id: ex.id }, routine, 'reps') === 'double'
|
||||
? { ...next, ...normalizeRepRange(next.reps, next.repsMin) }
|
||||
: next
|
||||
})
|
||||
const save = () => {
|
||||
close()
|
||||
const sets = Math.max(1, Math.round(c.sets) || (cardio ? 1 : 3))
|
||||
@@ -623,9 +648,15 @@ function ExConfig({ ex, existing, onSave, onDelete, close, routine, initial }) {
|
||||
// A unilateral target is stored even: the split has to divide, and a typed 15 would
|
||||
// otherwise plan seven reps on one side and eight on the other, every session.
|
||||
const typed = Math.max(1, Math.round(c.reps) || 10)
|
||||
const reps = perSide ? Math.ceil(typed / 2) * 2 : typed
|
||||
let reps = perSide ? Math.ceil(typed / 2) * 2 : typed
|
||||
let range = null
|
||||
if (double) {
|
||||
range = normalizeRepRange(reps, c.repsMin)
|
||||
if (perSide) range = normalizeRepRange(Math.ceil(range.reps / 2) * 2, range.repsMin)
|
||||
reps = range.reps
|
||||
}
|
||||
const out = { sets, mode: 'reps', reps, weight: Math.max(0, c.weight || 0), ...flags, ...(perSide ? { side: true } : {}), ...prog, ...withNote, ...withWarmups }
|
||||
if (policyFor({ ...c, id: ex.id }, routine, 'reps') === 'double') out.repsMin = Math.min(reps, Math.max(1, Math.round(c.repsMin) || Math.max(1, reps - 2)))
|
||||
if (double) out.repsMin = range.repsMin
|
||||
// A ceiling below the working reps would tell you to add a set on day one.
|
||||
if (bw && !(out.weight > 0) && c.repsMax > 0) out.repsMax = Math.max(reps, Math.round(c.repsMax))
|
||||
// Every set in this exercise becomes a drop-set/rest-pause (buildSets stamps the rows) —
|
||||
@@ -665,7 +696,7 @@ function ExConfig({ ex, existing, onSave, onDelete, close, routine, initial }) {
|
||||
rest-pause work set — so "Sets" has nothing left to mean and only invites a mismatch. */}
|
||||
{c.intensifier?.type !== 'restpause' &&
|
||||
<Stepper label={t('Sets')} value={c.sets} step={1} decimal={false} onChange={v => setC(x => ({ ...x, sets: v }))} />}
|
||||
<Stepper label={t('Reps')} value={c.reps} step={perSide ? 2 : 1} decimal={false} onChange={v => setC(x => ({ ...x, reps: v }))} />
|
||||
{!double && <Stepper label={t('Reps')} value={c.reps} step={perSide ? 2 : 1} decimal={false} onChange={v => setC(x => ({ ...x, reps: v }))} />}
|
||||
{/* On bodyweight work the weight stepper is the click #32 is about, so it is not here
|
||||
until there is a belt to describe — see the added-weight row below. */}
|
||||
{!bw && <Stepper label={t('Weight ({0})', st.unit)} value={c.weight} step={2.5} onChange={v => setC(x => ({ ...x, weight: v }))} />}
|
||||
|
||||
Reference in new issue
Block a user