feat: enhance training planning page with exercise variant support
Deploy Development / deploy (push) Successful in 34s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 6s
Test Suite / playwright-tests (push) Failing after 2m3s

- Introduced ExercisePickerModal for selecting exercises and their variants.
- Updated state management to handle exercise titles and variants in training units.
- Implemented enrichSectionsWithVariants function to fetch and integrate exercise details from the server.
- Improved loading logic for training units to include exercise variant data, enhancing user experience in planning sessions.
This commit is contained in:
Lars committed 2026-04-29 06:15:26 +02:00
1 parent 69b26fc928
commit 131b7d591d
3 files changed
+595 -40

No files matched your search

+22 -9
View File
@@ -23,17 +23,30 @@ async function request(endpoint, options = {}) {
headers['X-Auth-Token'] = token
}
const response = await fetch(`${API_URL}${endpoint}`, {
...options,
headers
})
const url = `${API_URL}${endpoint}`
if (!response.ok) {
const error = await response.json().catch(() => ({ detail: 'Unknown error' }))
throw new Error(error.detail || `HTTP ${response.status}`)
try {
const response = await fetch(url, {
...options,
headers,
})
if (!response.ok) {
const error = await response.json().catch(() => ({ detail: 'Unknown error' }))
throw new Error(error.detail || `HTTP ${response.status}`)
}
return response.json()
} catch (e) {
if (e instanceof TypeError && (e.message === 'Failed to fetch' || e.message.includes('fetch'))) {
const hint =
API_URL && API_URL.length > 0
? `Verbindung zum API unter ${API_URL} fehlgeschlagen. Läuft das Backend (z. B. Port 8098) und ist CORS erlaubt?`
: 'Kein VITE_API_URL gesetzt: Anfragen gehen an die Frontend-URL und schlagen oft fehl. Setze in .env z. B. VITE_API_URL=http://localhost:8098 und starte Vite neu.'
throw new Error(hint)
}
throw e
}
return response.json()
}
// ============================================================================