From 80cccdd2e09a55f959676873e51d3e298e07554c Mon Sep 17 00:00:00 2001 From: Duarte Santos Date: Fri, 4 Sep 2026 17:13:47 +0200 Subject: [PATCH] mrbatch (!87): Muskel-Explorer folgt dem Geraete-Profil wie Library/Picker, Zurueck-Pfeil links, Satz nicht doppelt, Library-Tab bleibt markiert --- frontend/src/components/MuscleExplorer.jsx | 19 +++++++++++++++++-- frontend/src/components/TabBar.jsx | 2 +- frontend/src/views/Muscles.jsx | 6 ++---- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/MuscleExplorer.jsx b/frontend/src/components/MuscleExplorer.jsx index d796a3b..e0cdfb6 100644 --- a/frontend/src/components/MuscleExplorer.jsx +++ b/frontend/src/components/MuscleExplorer.jsx @@ -1,6 +1,7 @@ import { useMemo, useState } from 'react' import { useStore } from '../store/useStore.js' import { BODYPARTS, allExercises, equipmentOf, matchExercise } from '../lib/exercises.js' +import { activeProfile, exAvailable } from '../lib/equipment.js' import { bestWeightFor } from '../lib/history.js' import { fmtNum } from '../lib/format.js' import { MUSCLES, MUSCLE_NAME, musclesOf } from '../lib/muscles.js' @@ -20,7 +21,14 @@ export default function MuscleExplorer({ onPick, onDetail, onPlan }) { const [bp, setBp] = useState('') const [eq, setEq] = useState('') const [shown, setShown] = useState(40) - const catalog = useMemo(() => allExercises(S), [S.customEx]) + const [showAll, setShowAll] = useState(false) // ignore the active equipment profile for this session + // Same rule as the Library and the picker: the active equipment profile narrows the catalogue + // (and the per-muscle counts) unless the user asks for everything. + const profile = activeProfile(S) + const catalog = useMemo(() => { + const all = allExercises(S) + return (profile && !showAll) ? all.filter(e => exAvailable(S, e)) : all + }, [S.customEx, S.equipFilterOn, S.activeEquipId, S.equipProfiles, showAll]) const counts = useMemo(() => Object.fromEntries(MUSCLES.map(m => [m, catalog.filter(e => musclesOf(e)[m]).length ])), [catalog]) @@ -33,6 +41,13 @@ export default function MuscleExplorer({ onPick, onDetail, onPlan }) { const choose = ex => onPick ? onPick(ex) : onDetail(ex) return <> + {profile &&
+ + {showAll ? t('Showing all equipment') : t('Showing what you have in "{0}"', profile.name)} + +
}
@@ -43,7 +58,7 @@ export default function MuscleExplorer({ onPick, onDetail, onPlan }) {
- {!selected &&
{t('Choose a muscle to see exercises that train it.')}
} + {!selected && onPick &&
{t('Choose a muscle to see exercises that train it.')}
} {selected && <>
diff --git a/frontend/src/components/TabBar.jsx b/frontend/src/components/TabBar.jsx index 156d4d7..d54e31c 100644 --- a/frontend/src/components/TabBar.jsx +++ b/frontend/src/components/TabBar.jsx @@ -13,7 +13,7 @@ export default function TabBar({ onStart }) { const isGuest = useStore(s => s.isGuest()) if (!user && !isGuest) return null const cur = loc.pathname.split('/')[1] || 'home' - const on = k => cur === k || (cur === 'history' && k === 'stats') || (cur === 'settings' && k === 'home') + const on = k => cur === k || (cur === 'history' && k === 'stats') || (cur === 'settings' && k === 'home') || (cur === 'muscles' && k === 'library') const startWorkout = () => { if (!S.active) { diff --git a/frontend/src/views/Muscles.jsx b/frontend/src/views/Muscles.jsx index 330a489..a1de3db 100644 --- a/frontend/src/views/Muscles.jsx +++ b/frontend/src/views/Muscles.jsx @@ -7,10 +7,8 @@ import Icon from '../components/Icon.jsx' export default function Muscles() { const nav = useNavigate() return <> -
-

{t('Explore muscles')}

{t('Choose a muscle to see exercises that train it.')}
- -
+
+

{t('Explore muscles')}

{t('Choose a muscle to see exercises that train it.')}