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.

feat(plan): show weekly muscle volume

Emil Zapata6031898a3ccc
diff --git a/frontend/src/views/Plan.jsx b/frontend/src/views/Plan.jsx
index 5e49475d4..ac153c166 100644
--- a/frontend/src/views/Plan.jsx
+++ b/frontend/src/views/Plan.jsx
@@ -1,6 +1,6 @@
import { useNavigate } from 'react-router-dom'
import { useStore } from '../store/useStore.js'
-import { DAYN, weekOrder, weekStartOf, uid, exCount, routineCount } from '../lib/format.js'
+import { DAYN, weekOrder, weekStartOf, uid, exCount, routineCount, fmtNum } from '../lib/format.js'
import { t } from '../lib/i18n.js'
import { dayAssignSheet, dayAddRoutineSheet, starterPlanSheet, planToolsSheet, confirmSheet } from '../sheets.jsx'
import Icon from '../components/Icon.jsx'
@@ -12,6 +12,7 @@ import { glyphOf, DEFAULT_GLYPH } from '../lib/glyphs.js'
import { DEMO } from '../lib/demo.js'
import { MOBILE } from '../lib/mobile.js'
import { coachAvailable } from '../lib/coach.js'
+import { loadOfWeeklyPlan, MUSCLE_NAME, rankOf } from '../lib/muscles.js'
export default function Plan() {
const nav = useNavigate()
@@ -20,6 +21,8 @@ export default function Plan() {
const config = useStore(s => s.config)
const coachMode = useStore(s => s.coachLocal?.mode)
const user = useStore(s => s.user)
+ const weeklyLoad = loadOfWeeklyPlan(S)
+ const weeklyMuscles = rankOf(weeklyLoad).worked
/* The Coach's only entry point in the app. Its screens have existed since the UI landed and
nothing linked to them, so the feature was reachable only by typing the URL — enabled,
@@ -101,6 +104,13 @@ export default function Plan() {
</div>
})}
</div>
+ <div className="card" data-weekly-muscle-volume style={{ marginTop: 12 }}>
+ <h2>{t('Weekly muscle volume')}</h2>
+ {weeklyMuscles.length ? weeklyMuscles.map(muscle => <div className="mrow" key={muscle}>
+ <span className="nm">{t(MUSCLE_NAME[muscle])}</span>
+ <span className="v">{t('{0} sets', fmtNum(Math.round(weeklyLoad[muscle] * 10) / 10))}</span>
+ </div>) : <div className="muted small">{t('No muscle volume planned.')}</div>}
+ </div>
</div><div>
<div className="row between" style={{ marginTop: 22, marginBottom: 10 }}>
<h4 className="sec" style={{ margin: 0 }}>{t('Routines')}</h4>
diff --git a/frontend/src/views/Plan.weekly-volume.test.jsx b/frontend/src/views/Plan.weekly-volume.test.jsx
new file mode 100644
index 000000000..92ed28c87
--- /dev/null
+++ b/frontend/src/views/Plan.weekly-volume.test.jsx
@@ -0,0 +1,53 @@
+// @vitest-environment happy-dom
+import React, { act } from 'react'
+import { createRoot } from 'react-dom/client'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { useStore } from '../store/useStore.js'
+import Plan from './Plan.jsx'
+
+vi.mock('react-router-dom', () => ({ useNavigate: () => vi.fn() }))
+vi.mock('../sheets.jsx', () => ({
+ dayAssignSheet: vi.fn(), dayAddRoutineSheet: vi.fn(), starterPlanSheet: vi.fn(), planToolsSheet: vi.fn(),
+}))
+
+const press = { id: 'press', n: 'Press', primaries: ['chest'], secondaries: ['triceps'], custom: true }
+const routines = [{ id: 'push', name: 'Push', emoji: null, ex: [{ id: press.id, sets: 2 }] }]
+let host, root
+
+beforeEach(() => {
+ globalThis.IS_REACT_ACT_ENVIRONMENT = true
+ host = document.createElement('div')
+ document.body.appendChild(host)
+ root = createRoot(host)
+ useStore.setState(s => ({
+ S: { ...s.S, lang: 'en', routines, customEx: [press], week: { 1: ['push'] }, dayPlan: {}, workouts: [] },
+ user: null,
+ }))
+})
+afterEach(() => { act(() => root.unmount()); host.remove() })
+
+const mount = () => act(() => root.render(<Plan />))
+const summary = () => host.querySelector('[data-weekly-muscle-volume]')
+
+describe('Plan — weekly muscle volume', () => {
+ it('shows every non-zero effective-set total from the recurring schedule', () => {
+ mount()
+ expect(summary().textContent).toContain('Weekly muscle volume')
+ expect(summary().textContent).toContain('Chest2 sets')
+ expect(summary().textContent).toContain('Triceps0.8 sets')
+ })
+
+ it('updates when the live weekly schedule changes', () => {
+ mount()
+ act(() => useStore.setState(s => ({ S: { ...s.S, week: { 1: ['push'], 3: 'push' } } })))
+ expect(summary().textContent).toContain('Chest4 sets')
+ expect(summary().textContent).toContain('Triceps1.6 sets')
+ })
+
+ it('keeps the summary mounted when the recurring plan has no volume', () => {
+ useStore.setState(s => ({ S: { ...s.S, week: { 1: ['stale'] } } }))
+ mount()
+ expect(summary().textContent).toContain('No muscle volume planned.')
+ expect(summary().querySelector('.mrow')).toBeNull()
+ })
+})