feat: import jen některých dnů

feat: násobení jídel/cviků
feat: refaktor napojování šablon
This commit is contained in:
Ondřej Anděl committed 2026-09-30 19:10:54 +02:00
1 parent c3990d80f8
commit 8dac67bdd1
37 files changed
+2314 -481

No files matched your search

+6
View File
@@ -117,6 +117,7 @@ const normalizeItem = (raw: unknown, index: number): WorkoutTemplateItem => {
}
const rate = value.caloriesPer100Units;
const sets = value.sets;
const extraWeight = value.extraWeightGrams;
return {
kind,
name,
@@ -129,6 +130,9 @@ const normalizeItem = (raw: unknown, index: number): WorkoutTemplateItem => {
...(typeof rate === 'number' && Number.isFinite(rate) && rate >= 0
? { caloriesPer100Units: Math.round(rate) }
: {}),
...(typeof extraWeight === 'number' && Number.isFinite(extraWeight) && extraWeight > 0
? { extraWeightGrams: Math.round(extraWeight) }
: {}),
};
};
@@ -269,6 +273,7 @@ export const applyWorkoutTemplate = async (login: string, id: unknown, date: unk
quantity: item.quantity!,
...(item.sets != null ? { sets: item.sets } : {}),
...(item.caloriesPer100Units != null ? { caloriesPer100Units: item.caloriesPer100Units } : {}),
...(item.extraWeightGrams != null ? { extraWeightGrams: item.extraWeightGrams } : {}),
calories: itemCalories(item),
templateId: template.id,
createdAt: now,
@@ -317,6 +322,7 @@ export const createWorkoutTemplateFromActivities = async (
...(entry.sets != null ? { sets: entry.sets } : {}),
// Aktivita se zadanými kaloriemi napevno sazbu nemá, šablona pak odhad nespočítá
...(entry.caloriesPer100Units != null ? { caloriesPer100Units: entry.caloriesPer100Units } : {}),
...(entry.extraWeightGrams != null ? { extraWeightGrams: entry.extraWeightGrams } : {}),
}));
return saveWorkoutTemplate(login, undefined, name, items);