fix: Better error handling for goal types loading
Build Test / lint-backend (push) Waiting to run
Build Test / build-frontend (push) Waiting to run
Deploy Development / deploy (push) Has been cancelled

- Check if goal_type_definitions table exists
- Detailed error messages
- Fallback if goalTypes is empty
- Prevent form opening without types

Helps debugging Migration 024 issues.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Opus 4.6 committed 2026-03-27 07:28:14 +01:00
1 parent 043bed4323
commit bbee44ecdc
2 files changed
+63 -29

No files matched your search

+18 -12
View File
@@ -84,21 +84,23 @@ export default function GoalsPage() {
// Convert types array to map for quick lookup
const typesMap = {}
typesData.forEach(type => {
typesMap[type.type_key] = {
label: type.label_de,
unit: type.unit,
icon: type.icon || '📊',
category: type.category,
is_system: type.is_system
}
})
if (typesData && Array.isArray(typesData)) {
typesData.forEach(type => {
typesMap[type.type_key] = {
label: type.label_de,
unit: type.unit,
icon: type.icon || '📊',
category: type.category,
is_system: type.is_system
}
})
}
setGoalTypes(typesData)
setGoalTypes(typesData || [])
setGoalTypesMap(typesMap)
} catch (err) {
console.error('Failed to load goals:', err)
setError('Fehler beim Laden der Ziele')
setError(`Fehler beim Laden: ${err.message || err.toString()}`)
} finally {
setLoading(false)
}
@@ -121,8 +123,12 @@ export default function GoalsPage() {
}
const handleCreateGoal = () => {
if (goalTypes.length === 0) {
setError('Keine Goal Types verfügbar. Bitte Admin kontaktieren.')
return
}
setEditingGoal(null)
const firstType = goalTypes.length > 0 ? goalTypes[0].type_key : 'weight'
const firstType = goalTypes[0].type_key
setFormData({
goal_type: firstType,
is_primary: goals.length === 0, // First goal is primary by default