feat: enhance SQL query handling and UI components for exercise management
Deploy Development / deploy (push) Successful in 36s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 5s
Test Suite / playwright-tests (push) Has been cancelled

- Introduced a new utility function to streamline SQL query construction for active status filtering, improving code reusability across multiple endpoints.
- Updated existing query logic in the catalogs and skills routers to utilize the new utility function, ensuring consistent handling of active status.
- Refactored the ExerciseFormPage to remove deprecated age group handling, simplifying the form structure.
- Enhanced the RichTextEditor component with improved link handling and formatting options for better user experience.
- Updated API utility functions to support new AI features for exercise suggestions and regeneration, expanding the capabilities of the exercise management system.
This commit is contained in:
Lars committed 2026-04-27 15:01:47 +02:00
1 parent d8f439a3e5
commit 0ad096e483
7 files changed
+129 -84

No files matched your search

+13 -29
View File
@@ -19,8 +19,6 @@ const LEVEL_OPTIONS = [
{ value: 'experte', label: 'Experte' },
]
const AGE_GROUP_OPTIONS = ['Minis', 'Kinder', 'Schüler', 'Teenager', 'Erwachsene']
function emptyForm() {
return {
title: '',
@@ -34,7 +32,6 @@ function emptyForm() {
duration_max: '',
group_size_min: '',
group_size_max: '',
age_groups: [],
focus_areas_multi: [],
training_styles_multi: [],
training_types_multi: [],
@@ -58,7 +55,6 @@ function detailToForm(exercise) {
duration_max: exercise.duration_max ?? '',
group_size_min: exercise.group_size_min ?? '',
group_size_max: exercise.group_size_max ?? '',
age_groups: exercise.age_groups || [],
focus_areas_multi: (exercise.focus_areas || []).map((f) => ({
focus_area_id: f.focus_area_id,
is_primary: !!f.is_primary,
@@ -195,7 +191,13 @@ function ExerciseFormPage() {
setTrainingTypes(ttData)
setTargetGroups(tgData)
} catch (e) {
if (!cancelled) console.error(e)
if (!cancelled) {
console.error(e)
alert(
'Kataloge (Fokus, Stile, Zielgruppen, Fähigkeiten) konnten nicht geladen werden: ' +
(e.message || e),
)
}
}
}
boot()
@@ -238,13 +240,6 @@ function ExerciseFormPage() {
setFormData((prev) => ({ ...prev, [field]: value }))
}
const toggleAgeGroup = (name) => {
const set = new Set(formData.age_groups)
if (set.has(name)) set.delete(name)
else set.add(name)
updateFormField('age_groups', [...set])
}
const addSkillRow = () => {
const id = skillPick ? parseInt(skillPick, 10) : null
if (!id) {
@@ -545,22 +540,6 @@ function ExerciseFormPage() {
</div>
</div>
<div className="form-row">
<label className="form-label">Altersgruppen (Katalog)</label>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '8px' }}>
{AGE_GROUP_OPTIONS.map((ag) => (
<label key={ag} style={{ fontSize: '14px', display: 'flex', alignItems: 'center', gap: '4px' }}>
<input
type="checkbox"
checked={formData.age_groups.includes(ag)}
onChange={() => toggleAgeGroup(ag)}
/>
{ag}
</label>
))}
</div>
</div>
<MultiAssocBlock
title="Fokusbereiche (0…n, ein „primär“)"
rows={formData.focus_areas_multi}
@@ -812,7 +791,12 @@ function ExerciseFormPage() {
)}
<p style={{ fontSize: '12px', color: 'var(--text3)', marginTop: '16px' }}>
Varianten-Editor folgt in einem späteren Schritt (API ist teilweise vorhanden).
Varianten-Editor folgt später (API teilweise vorhanden).{' '}
<strong>KI-Ausbaustufe:</strong> Backend laut Spec{' '}
<code style={{ fontSize: '11px' }}>POST /api/exercises/ai/suggest</code> und{' '}
<code style={{ fontSize: '11px' }}>POST /api/exercises/{'{id}'}/ai/regenerate</code> — z. B.{' '}
<code>OPENROUTER_API_KEY</code>, Vorschläge nur nach Trainer-Bestätigung übernehmen (siehe{' '}
<code>api.suggestExerciseAi</code>).
</p>
</div>
)