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.

CSV export: no "0 measurements" under the body file (#647)

Duarte Santosd94ee1ec2527
diff --git a/frontend/src/components/CsvExportSheet.jsx b/frontend/src/components/CsvExportSheet.jsx
index 093d5c48a..76f492acd 100644
--- a/frontend/src/components/CsvExportSheet.jsx
+++ b/frontend/src/components/CsvExportSheet.jsx
@@ -63,7 +63,7 @@ export function CsvExportSheet({ close }) {
</div>
<Button icon="share" onClick={() => save('body')}>{t('Body weight & measurements (CSV)')}</Button>
<div className="small dim" style={{ margin: '4px 2px 0' }} data-csv-count="body">
- {tn('{0} weigh-in', '{0} weigh-ins', counts.weighIns) + ' · ' + tn('{0} measurement', '{0} measurements', counts.measurements)}
+ {tn('{0} weigh-in', '{0} weigh-ins', counts.weighIns) + (counts.measurements ? ' · ' + tn('{0} measurement', '{0} measurements', counts.measurements) : '')}
</div>
</>
}
diff --git a/frontend/src/components/CsvExportSheet.test.jsx b/frontend/src/components/CsvExportSheet.test.jsx
index 300b626d1..5608acd99 100644
--- a/frontend/src/components/CsvExportSheet.test.jsx
+++ b/frontend/src/components/CsvExportSheet.test.jsx
@@ -63,6 +63,10 @@ describe('CsvExportSheet', () => {
expect(count('body')).toBe('1 weigh-in · 1 measurement')
})
+ it('leaves measurements out of the line when there are none', () => {
+ expect(count('body')).toBe('1 weigh-in')
+ })
+
it('shares the workouts file on the phone, named by the day', async () => {
act(() => button('4 weeks').click())
act(() => button('Workouts (CSV)').click())