Goalsystem V1 #50
|
|
@ -22,6 +22,39 @@ const PRIORITY_LEVELS = {
|
||||||
3: { label: 'Niedrig', stars: '⭐', color: '#CBD5E1' }
|
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() {
|
export default function GoalsPage() {
|
||||||
const [goalMode, setGoalMode] = useState(null)
|
const [goalMode, setGoalMode] = useState(null)
|
||||||
const [focusAreas, setFocusAreas] = useState(null)
|
const [focusAreas, setFocusAreas] = useState(null)
|
||||||
|
|
@ -141,7 +174,7 @@ export default function GoalsPage() {
|
||||||
setFormData({
|
setFormData({
|
||||||
goal_type: firstType,
|
goal_type: firstType,
|
||||||
is_primary: goals.length === 0, // First goal is primary by default
|
is_primary: goals.length === 0, // First goal is primary by default
|
||||||
category: 'body',
|
category: getCategoryForGoalType(firstType), // Auto-assign based on type
|
||||||
priority: 2,
|
priority: 2,
|
||||||
target_value: '',
|
target_value: '',
|
||||||
unit: goalTypesMap[firstType]?.unit || 'kg',
|
unit: goalTypesMap[firstType]?.unit || 'kg',
|
||||||
|
|
@ -172,7 +205,8 @@ export default function GoalsPage() {
|
||||||
setFormData(f => ({
|
setFormData(f => ({
|
||||||
...f,
|
...f,
|
||||||
goal_type: type,
|
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