Fix adding new set with no plan

Closes #36
This commit is contained in:
Brandon Presley 2022-09-22 14:32:37 +12:00
parent 5da73a0e3e
commit f320d16c4b
4 changed files with 5 additions and 12 deletions

View File

@ -47,7 +47,7 @@ export default function SetList() {
if (!settings.predict) return setSet({...defaultSet});
const todaysPlan = await getTodaysPlan();
console.log(`${SetList.name}.predict:`, {todaysPlan});
if (todaysPlan.length === 0) return;
if (todaysPlan.length === 0) return setSet({...defaultSet});
const todaysSets = await getTodaysSets();
const todaysWorkouts = todaysPlan[0].workouts.split(',');
let workout = todaysWorkouts[0];
@ -114,6 +114,7 @@ export default function SetList() {
}, [search, end, offset, sets]);
const onAdd = useCallback(async () => {
console.log(`${SetList.name}.onAdd`, {set, defaultSet, workouts});
navigation.navigate('EditSet', {
set: set || {...defaultSet},
workouts,

View File

@ -1,6 +1,7 @@
import {db, defaultSet} from './db';
import {db} from './db';
import {Periods} from './periods';
import Set from './set';
import {defaultSet} from './set.service';
import Volume from './volume';
export const getBestSet = async (name: string): Promise<Set> => {

8
db.ts
View File

@ -140,11 +140,3 @@ export interface PageParams {
limit: number;
offset: number;
}
export const defaultSet = {
name: '',
id: 0,
reps: 10,
weight: 20,
unit: 'kg',
};

View File

@ -84,9 +84,8 @@ export const getTodaysSets = async (): Promise<Set[]> => {
return result.rows.raw();
};
export const defaultSet = {
export const defaultSet: Set = {
name: '',
id: 0,
reps: 10,
weight: 20,
unit: 'kg',