feat: auto-assign goal category based on goal type
Added intelligent category assignment: - Weight, body_fat, lean_mass → Körper - Strength, flexibility → Training - BP, VO2Max, RHR, HRV → Gesundheit - Sleep goals → Erholung - Nutrition goals → Ernährung - Unknown types → Sonstiges Changes: 1. getCategoryForGoalType() mapping function 2. Auto-set category in handleGoalTypeChange() 3. Auto-set category in handleCreateGoal() User can still manually change category if needed. Fixes: Blood pressure goals wrongly categorized as 'Training' Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
498ad7a47f
commit
db90f397e8
|
|
@ -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
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user