curated2: log a past workout — History entry point, date/time/duration/routine sheet, replace-or-add prompt, workout screen without clock or rest timers, no PRs or confirmed weights on finish
This commit is contained in:
1 parent
346e1110c7
commit
95f8346124
4 files changed
+167
-21
No files matched your search
@@ -1,7 +1,8 @@
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { useStore } from '../store/useStore.js'
|
||||
import { t } from '../lib/i18n.js'
|
||||
import { WorkoutRow, workoutDetailSheet } from '../sheets.jsx'
|
||||
import { WorkoutRow, workoutDetailSheet, logPastWorkoutSheet } from '../sheets.jsx'
|
||||
import { Button } from '../components/ui.jsx'
|
||||
import Icon from '../components/Icon.jsx'
|
||||
|
||||
export default function History() {
|
||||
@@ -10,6 +11,7 @@ export default function History() {
|
||||
return <>
|
||||
<div className="hdr"><button className="iconbtn" onClick={() => nav('/stats')} aria-label={t('Stats')}><Icon name="chevronLeft" /></button>
|
||||
<div style={{ flex: 1, marginLeft: 12 }}><h1>{t('History')}</h1><div className="sub">{t('{0} workouts', S.workouts.length)}</div></div></div>
|
||||
<Button icon="plus" onClick={logPastWorkoutSheet} style={{ marginBottom: 12 }}>{t('Log a past workout')}</Button>
|
||||
{S.workouts.length ? <div className="list">{[...S.workouts].reverse().map(w => <WorkoutRow key={w.id} w={w} onClick={() => workoutDetailSheet(w)} />)}</div>
|
||||
: <div className="empty"><div className="ico"><Icon name="history" /></div>{t('No workouts yet.')}</div>}
|
||||
</>
|
||||
|
||||
@@ -290,8 +290,11 @@ function ActiveWorkout() {
|
||||
const nav = useNavigate()
|
||||
const S = useStore(s => s.S)
|
||||
const update = useStore(s => s.update)
|
||||
const { startRest, stopRest, stopWork, work } = useUI()
|
||||
const { startRest: liveRest, stopRest, stopWork, work } = useUI()
|
||||
const A = S.active
|
||||
// A past workout has no rest to time — the sets were done days ago. The work timer for
|
||||
// timed sets stays, since counting a hold is how its duration gets entered.
|
||||
const startRest = A.backfill ? () => {} : liveRest
|
||||
const units = supersetUnits(A.entries)
|
||||
const cur = Number.isInteger(A.cur)
|
||||
? Math.min(Math.max(A.cur, 0), Math.max(0, A.entries.length - 1))
|
||||
@@ -613,10 +616,11 @@ function ActiveWorkout() {
|
||||
return <div className="narrow">
|
||||
<div className="hdr">
|
||||
<button className="iconbtn" aria-label={t('Discard')} onClick={() => confirmSheet({ title: t('Discard workout?'), message: t('The sets you logged in this session will be lost.'), confirmText: t('Discard'), danger: true, onConfirm: () => { update(s => { s.active = null }); stopRest(); stopWork(); nav('/home') } })}><Icon name="xmark" /></button>
|
||||
<div style={{ textAlign: 'center' }}><div style={{ fontWeight: 600 }}>{A.name}</div><div className="sub"><Elapsed start={A.start} /> · {t('{0} sets', done + '/' + total)}</div></div>
|
||||
<div style={{ textAlign: 'center' }}><div style={{ fontWeight: 600 }}>{A.name}</div><div className="sub">{A.backfill ? fmtDate(A.d, true) : <Elapsed start={A.start} />} · {t('{0} sets', done + '/' + total)}</div></div>
|
||||
<button className="iconbtn" style={{ color: 'var(--acc)' }} aria-label={t('Finish')} onClick={finishWorkout}><Icon name="check" /></button>
|
||||
</div>
|
||||
<div className="wprog"><i style={{ width: (total ? done / total * 100 : 0) + '%' }} /></div>
|
||||
{A.backfill && <div className="muted small" style={{ marginBottom: 8 }}>{t('Logging a past workout — no rest timers.')}</div>}
|
||||
|
||||
{A.entries.length ? <>
|
||||
<div className="muted small" style={{ marginBottom: 6 }}>{isSuperset ? t('Superset {0} / {1}', unitIdx + 1, units.length) : t('Exercise {0} / {1}', unitIdx + 1, units.length)}</div>
|
||||
|
||||
Reference in new issue
Block a user