From 37803ad0d43517c5bb5ba617758639a3c478e816 Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Tue, 23 Aug 2022 16:01:16 +1200 Subject: [PATCH] Set default set to 10x20kg I want the default set to be the most common set a person might do as a warm-up. 10x20kg might be a warmup for deadlifts where you are just lifting the bar. Same goes for squats, romanian deadlifts or rows. --- SetList.tsx | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/SetList.tsx b/SetList.tsx index 94abe7a..b1eb313 100644 --- a/SetList.tsx +++ b/SetList.tsx @@ -16,6 +16,13 @@ import SetItem from './SetItem'; import {DAYS} from './time'; const limit = 15; +const defaultSet = { + name: '', + id: 0, + reps: 10, + weight: 20, + unit: 'kg', +}; export default function SetList() { const [sets, setSets] = useState(); @@ -87,13 +94,7 @@ export default function SetList() { GROUP BY name; `; const [weightResult] = await db.executeSql(bestWeight, [query]); - if (!weightResult.rows.length) - return { - weight: 0, - name: '', - reps: 0, - id: 0, - }; + if (!weightResult.rows.length) return {...defaultSet}; const [repsResult] = await db.executeSql(bestReps, [ query, weightResult.rows.item(0).weight, @@ -165,13 +166,7 @@ export default function SetList() { }, [search, end, offset, sets, db, selectSets]); const onAdd = useCallback(async () => { - const set: Set = { - name: '', - id: 0, - reps: 5, - weight: 1, - unit: 'kg', - }; + const set: Set = {...defaultSet}; navigation.navigate('EditSet', {set: nextSet || set}); }, [navigation, nextSet]);