Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Merge pull request #633: fix(coach): keep the intake's weekdays in step with the day count (@Jul11us)

Duarte Santos3b8cf6d55507
diff --cc frontend/src/views/CoachIntake.jsx
index 90d991d51,c98c594ad..8fa54fda1
--- a/frontend/src/views/CoachIntake.jsx
+++ b/frontend/src/views/CoachIntake.jsx
@@@ -15,11 -15,9 +15,11 @@@ import { useUI } from '../store/useUI.j
import { t } from '../lib/i18n.js'
import { DAYN } from '../lib/format.js'
import { EXDB } from '../lib/exercises.js'
- import { emptyCoach, coachAvailable, hasConsent, CONSENT_VERSION, CATEGORY_TEXT, appendChat } from '../lib/coach.js'
+ import { emptyCoach, coachAvailable, hasConsent, CONSENT_VERSION, CATEGORY_TEXT, appendChat, defaultTrainingDays } from '../lib/coach.js'
-import { requestPlan, disclosure, JOB_ERRORS } from '../lib/coach-api.js'
+import { requestPlan, disclosure, JOB_ERRORS, isDeclined, coachVia } from '../lib/coach-api.js'
+import { consentTarget, allowAi } from '../lib/coach-consent.js'
import { DEMO } from '../lib/demo.js'
+import { useCoachGate } from '../lib/use-coach-gate.js'
import { MOBILE } from '../lib/mobile.js'
import { activeProfile } from '../lib/equipment.js'
import Icon from '../components/Icon.jsx'
@@@ -53,7 -50,9 +53,8 @@@ const EQUIPMENT = (() =>
})()
const QUICK_MIN = [30, 45, 60, 90]
+ const sameDays = (a, b) => a.length === b.length && b.every(d => a.includes(d))
-const toHHMM = min => String(Math.floor(min / 60)).padStart(2, '0') + ':' + String(min % 60).padStart(2, '0')
-const fromHHMM = v => { const [h, m] = String(v || '').split(':').map(Number); return Number.isFinite(h) && Number.isFinite(m) ? h * 60 + m : null }
+const toHHMM = min => Math.floor(min / 60) + ':' + String(min % 60).padStart(2, '0')
export default function CoachIntake() {
const nav = useNavigate()
@@@ -175,19 -172,12 +184,19 @@@
<div className="ob-eyebrow">{t('Schedule')}</div>
<h1 className="ob-h">{t('How many days a week?')}</h1>
<p className="ob-p">{t('Pick what you will actually keep, not the best week you can imagine.')}</p>
- <div className="ob-days">
- {[1, 2, 3, 4, 5, 6, 7].map(n => <button key={n} className={'ob-day' + (p.daysPerWeek === n ? ' on' : '')} onClick={() => setDays(n)}>{n}</button>)}
+ {/* Two questions, two groups: how many (a count), then which (weekdays, optional). Each
+ has its own label, so the row of numbers never reads as dates. */}
+ <div className="ob-group" role="group" aria-labelledby="ob-days-l">
+ <div className="ob-sub ob-sub-first" id="ob-days-l">{t('Days per week')}</div>
+ <div className="ob-days">
- {[1, 2, 3, 4, 5, 6, 7].map(n => <button key={n} className={'ob-day' + (p.daysPerWeek === n ? ' on' : '')} aria-pressed={p.daysPerWeek === n} onClick={() => set({ daysPerWeek: n })}>{n}</button>)}
++ {[1, 2, 3, 4, 5, 6, 7].map(n => <button key={n} className={'ob-day' + (p.daysPerWeek === n ? ' on' : '')} aria-pressed={p.daysPerWeek === n} onClick={() => setDays(n)}>{n}</button>)}
+ </div>
</div>
- <div className="ob-sub">{t('Which days suit you? (optional)')}</div>
- <div className="ob-week">
- {[1, 2, 3, 4, 5, 6, 0].map(d => <button key={d} className={'ob-wd' + (p.preferredDays.includes(d) ? ' on' : '')} onClick={() => toggleDay(d)}>{t(DAYN[d]).slice(0, 2)}</button>)}
+ <div className="ob-group" role="group" aria-labelledby="ob-week-l">
+ <div className="ob-sub ob-sub-first" id="ob-week-l">{t('Which days suit you? (optional)')}</div>
+ <div className="ob-week">
+ {[1, 2, 3, 4, 5, 6, 0].map(d => <button key={d} className={'ob-wd' + (p.preferredDays.includes(d) ? ' on' : '')} aria-pressed={p.preferredDays.includes(d)} onClick={() => toggleDay(d)}>{t(DAYN[d]).slice(0, 2)}</button>)}
+ </div>
</div>
</>}