Fix adding plan

This commit is contained in:
Brandon Presley 2022-07-10 16:10:06 +12:00
parent 7ff0e1c8de
commit 52a4eada94
1 changed files with 2 additions and 1 deletions

View File

@ -34,10 +34,11 @@ export default function EditPlan({
}, [plan, db]);
const save = useCallback(async () => {
console.log(`${EditPlan.name}.save`, {days, workouts, plan});
if (!days || !workouts) return;
const newWorkouts = workouts.filter(workout => workout).join(',');
const newDays = days.filter(day => day).join(',');
if (!plan)
if (!plan?.id)
await db.executeSql(`INSERT INTO plans(days, workouts) VALUES (?, ?)`, [
newDays,
newWorkouts,