diff --git a/frontend/src/pages/GoalsPage.jsx b/frontend/src/pages/GoalsPage.jsx index 275fff5..d27cdf8 100644 --- a/frontend/src/pages/GoalsPage.jsx +++ b/frontend/src/pages/GoalsPage.jsx @@ -22,6 +22,39 @@ const PRIORITY_LEVELS = { 3: { label: 'Niedrig', stars: '⭐', color: '#CBD5E1' } } +// Auto-assign category based on goal_type +const getCategoryForGoalType = (goalType) => { + const mapping = { + // Body composition + 'weight': 'body', + 'body_fat': 'body', + 'lean_mass': 'body', + + // Training + 'strength': 'training', + 'flexibility': 'training', + 'training_frequency': 'training', + + // Health/Vitals + 'vo2max': 'health', + 'rhr': 'health', + 'bp': 'health', + 'hrv': 'health', + + // Recovery + 'sleep_quality': 'recovery', + 'sleep_duration': 'recovery', + 'rest_days': 'recovery', + + // Nutrition + 'calories': 'nutrition', + 'protein': 'nutrition', + 'healthy_eating': 'nutrition' + } + + return mapping[goalType] || 'other' +} + export default function GoalsPage() { const [goalMode, setGoalMode] = useState(null) const [focusAreas, setFocusAreas] = useState(null) @@ -141,7 +174,7 @@ export default function GoalsPage() { setFormData({ goal_type: firstType, is_primary: goals.length === 0, // First goal is primary by default - category: 'body', + category: getCategoryForGoalType(firstType), // Auto-assign based on type priority: 2, target_value: '', unit: goalTypesMap[firstType]?.unit || 'kg', @@ -172,7 +205,8 @@ export default function GoalsPage() { setFormData(f => ({ ...f, goal_type: type, - unit: goalTypesMap[type]?.unit || 'unit' + unit: goalTypesMap[type]?.unit || 'unit', + category: getCategoryForGoalType(type) // Auto-assign category })) }