custom cardio exercises now have a default target muscle and an option add secondary muscles
This commit is contained in:
1 parent
3f538268e8
commit
8ae5cdb060
2 files changed
+8
-6
No files matched your search
@@ -30,7 +30,7 @@ export const MUSCLE_NAME = {
|
||||
serratus: 'Serratus', biceps: 'Biceps', triceps: 'Triceps', forearm: 'Forearms',
|
||||
abs: 'Abs', obliques: 'Obliques', 'lower-back': 'Lower back', gluteal: 'Glutes',
|
||||
quadriceps: 'Quads', hamstring: 'Hamstrings', adductors: 'Adductors',
|
||||
'hip-flexors': 'Hip flexors', calves: 'Calves', tibialis: 'Shins',
|
||||
'hip-flexors': 'Hip flexors', calves: 'Calves', tibialis: 'Shins', 'cardiovascular system': 'Cardiovascular system',
|
||||
}
|
||||
|
||||
// Every spelling that occurs in the dataset's `tg` and `sm` fields. null = not drawable.
|
||||
@@ -40,7 +40,7 @@ const ALIAS = {
|
||||
triceps: 'triceps', 'upper back': 'upper-back', lats: 'upper-back', calves: 'calves',
|
||||
quads: 'quadriceps', forearms: 'forearm', hamstrings: 'hamstring', spine: 'lower-back',
|
||||
traps: 'trapezius', adductors: 'adductors', 'serratus anterior': 'serratus',
|
||||
abductors: 'gluteal', 'levator scapulae': 'trapezius', 'cardiovascular system': null,
|
||||
abductors: 'gluteal', 'levator scapulae': 'trapezius', 'cardiovascular system': 'cardiovascular system',
|
||||
// secondaries
|
||||
shoulders: 'deltoids', deltoids: 'deltoids', 'rear deltoids': 'deltoids',
|
||||
'rotator cuff': 'deltoids', quadriceps: 'quadriceps', core: 'abs', abdominals: 'abs',
|
||||
|
||||
@@ -643,7 +643,7 @@ function ExerciseDetail({ ex, close }) {
|
||||
<Media ex={ex} />
|
||||
<div className="row" style={{ gap: 6, flexWrap: 'wrap', margin: '10px 0' }}>
|
||||
<span className="tag acc">{t(ex.bp)}</span>
|
||||
{(ex.primaries?.length ? ex.primaries : (ex.tg ? [ex.tg] : [])).map((s, i) => <span key={i} className="tag"><Icon name="target" />{t(MUSCLE_NAME[s] || s)}</span>)}
|
||||
{ex.bp === 'cardio' ? <span className="tag"><Icon name="target" />{t(MUSCLE_NAME['cardiovascular system'])}</span> : (ex.primaries?.length ? ex.primaries : (ex.tg ? [ex.tg] : [])).map((s, i) => <span key={i} className="tag"><Icon name="target" />{t(MUSCLE_NAME[s] || s)}</span>)}
|
||||
<span className="tag"><Icon name="dumbbell" />{t(ex.eq)}</span>
|
||||
{(ex.secondaries?.length ? ex.secondaries : smOf(ex)).slice(0, 3).map((s, i) => <span key={i} className="tag">{t(MUSCLE_NAME[s] || s)}</span>)}
|
||||
</div>
|
||||
@@ -759,6 +759,7 @@ function CustomExForm({ existing, prefill, onDone, close }) {
|
||||
const [desc, setDesc] = useState(existing ? (existing.desc || '') : '')
|
||||
const [primaries, setPrimaries] = useState(() => {
|
||||
if (existing && Array.isArray(existing.primaries) && existing.primaries.length) return [...existing.primaries]
|
||||
if (existing?.bp === 'cardio') return ['cardiovascular system']
|
||||
const norm = hasExplicitMuscleMetadata(existing || {}) ? normalizeMuscleGroups(existing || {}) : []
|
||||
return norm.length ? [norm[0]] : []
|
||||
})
|
||||
@@ -776,7 +777,7 @@ function CustomExForm({ existing, prefill, onDone, close }) {
|
||||
const dup = allExercises(S()).find(e => e.n.toLowerCase() === name.toLowerCase() && e.id !== (existing || {}).id)
|
||||
if (dup) { toast(t('“{0}” already exists', dup.n)); return }
|
||||
const d = desc.trim().slice(0, 1000)
|
||||
const prim = [...primaries]
|
||||
const prim = bp === 'cardio' ? ['cardiovascular system'] : [...primaries]
|
||||
const sm = secondaries.filter(m => !prim.includes(m))
|
||||
const groups = [...prim, ...sm]
|
||||
let id = existing && existing.id
|
||||
@@ -798,11 +799,12 @@ function CustomExForm({ existing, prefill, onDone, close }) {
|
||||
<div className="chips" style={{ margin: '12px 0' }}>
|
||||
{BODYPARTS.map(b => <button key={b} className={'chip' + (bp === b ? ' on' : '')} onClick={() => setBp(b)}>{t(b)}</button>)}
|
||||
</div>
|
||||
{bp && bp !== 'cardio' && <>
|
||||
<MultiSelectRow title={t('Primary muscle groups')} sheetTitle={t('Primary muscle groups')}
|
||||
{bp && <>
|
||||
{bp !== 'cardio' && <MultiSelectRow title={t('Primary muscle groups')} sheetTitle={t('Primary muscle groups')}
|
||||
values={primaries}
|
||||
options={MUSCLES.map(m => ({ value: m, label: t(MUSCLE_NAME[m]) }))}
|
||||
onToggle={togglePrimary} noneLabel={t('No explicit muscle group')} doneLabel={t('Done')} />
|
||||
}
|
||||
<MultiSelectRow title={t('Additional muscle groups')} sheetTitle={t('Additional muscle groups')}
|
||||
values={secondaries}
|
||||
options={MUSCLES.filter(m => !primaries.includes(m)).map(m => ({ value: m, label: t(MUSCLE_NAME[m]) }))}
|
||||
|
||||
Reference in new issue
Block a user