feat: enhance exercise mapping and filtering capabilities
- Added support for style direction mappings in the backend, allowing for improved categorization of exercises. - Introduced a new function to normalize property synonyms, enhancing the mapping of exercise properties. - Updated the exercise catalog assignment logic to include style directions, ensuring proper database entries. - Enhanced the ExercisesListPage with new filtering options for style directions, improving user experience and search capabilities.
This commit is contained in:
1 parent
76098f5244
commit
025b161d2f
4 files changed
+254
-118
No files matched your search
@@ -2,6 +2,7 @@ import React, { useState, useEffect, useMemo } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import api from '../utils/api'
|
||||
import { SKILL_LEVEL_OPTIONS } from '../constants/skillLevels'
|
||||
import SearchableSelect from '../components/SearchableSelect'
|
||||
|
||||
const PAGE_SIZE = 100
|
||||
const LEVEL_FILTER_OPTS = SKILL_LEVEL_OPTIONS.filter((o) => o.level != null)
|
||||
@@ -46,6 +47,52 @@ function ExercisesListPage() {
|
||||
return () => clearTimeout(t)
|
||||
}, [aiSearchInput])
|
||||
|
||||
const focusOptions = useMemo(
|
||||
() =>
|
||||
catalogs.focusAreas.map((fa) => ({
|
||||
id: fa.id,
|
||||
label: `${fa.icon || ''} ${fa.name || ''}`.trim(),
|
||||
})),
|
||||
[catalogs.focusAreas]
|
||||
)
|
||||
const styleOptions = useMemo(
|
||||
() => catalogs.styleDirections.map((s) => ({ id: s.id, label: s.name || String(s.id) })),
|
||||
[catalogs.styleDirections]
|
||||
)
|
||||
const trainingTypeOptions = useMemo(
|
||||
() => catalogs.trainingTypes.map((t) => ({ id: t.id, label: t.name || String(t.id) })),
|
||||
[catalogs.trainingTypes]
|
||||
)
|
||||
const targetGroupOptions = useMemo(
|
||||
() => catalogs.targetGroups.map((g) => ({ id: g.id, label: g.name || String(g.id) })),
|
||||
[catalogs.targetGroups]
|
||||
)
|
||||
const skillOptions = useMemo(
|
||||
() => catalogs.skills.map((s) => ({ id: s.id, label: s.name || String(s.id) })),
|
||||
[catalogs.skills]
|
||||
)
|
||||
const levelFilterOptions = useMemo(
|
||||
() => LEVEL_FILTER_OPTS.map((o) => ({ id: o.level, label: o.label })),
|
||||
[]
|
||||
)
|
||||
const visibilityOptions = useMemo(
|
||||
() => [
|
||||
{ id: 'private', label: 'Privat' },
|
||||
{ id: 'club', label: 'Verein' },
|
||||
{ id: 'official', label: 'Offiziell' },
|
||||
],
|
||||
[]
|
||||
)
|
||||
const statusOptions = useMemo(
|
||||
() => [
|
||||
{ id: 'draft', label: 'Entwurf' },
|
||||
{ id: 'in_review', label: 'In Prüfung' },
|
||||
{ id: 'approved', label: 'Freigegeben' },
|
||||
{ id: 'archived', label: 'Archiviert' },
|
||||
],
|
||||
[]
|
||||
)
|
||||
|
||||
const queryBase = useMemo(() => {
|
||||
const q = {}
|
||||
const n = (v) => (v === '' || v == null ? undefined : Number(v))
|
||||
@@ -205,135 +252,93 @@ function ExercisesListPage() {
|
||||
</div>
|
||||
<div>
|
||||
<label className="form-label">Fokus</label>
|
||||
<select
|
||||
className="form-input"
|
||||
<SearchableSelect
|
||||
value={filters.focus_area}
|
||||
onChange={(e) => setFilters({ ...filters, focus_area: e.target.value })}
|
||||
>
|
||||
<option value="">Alle</option>
|
||||
{catalogs.focusAreas.map((fa) => (
|
||||
<option key={fa.id} value={fa.id}>
|
||||
{fa.icon} {fa.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
onChange={(v) => setFilters({ ...filters, focus_area: v })}
|
||||
options={focusOptions}
|
||||
allLabel="Alle Fokusbereiche"
|
||||
filterPlaceholder="Fokus filtern…"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="form-label">Stilrichtung</label>
|
||||
<select
|
||||
className="form-input"
|
||||
<SearchableSelect
|
||||
value={filters.style_direction_id}
|
||||
onChange={(e) => setFilters({ ...filters, style_direction_id: e.target.value })}
|
||||
>
|
||||
<option value="">Alle</option>
|
||||
{catalogs.styleDirections.map((s) => (
|
||||
<option key={s.id} value={s.id}>
|
||||
{s.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
onChange={(v) => setFilters({ ...filters, style_direction_id: v })}
|
||||
options={styleOptions}
|
||||
allLabel="Alle Stilrichtungen"
|
||||
filterPlaceholder="Stilrichtung filtern…"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="form-label">Trainingsstil</label>
|
||||
<select
|
||||
className="form-input"
|
||||
<SearchableSelect
|
||||
value={filters.training_type_id}
|
||||
onChange={(e) => setFilters({ ...filters, training_type_id: e.target.value })}
|
||||
>
|
||||
<option value="">Alle</option>
|
||||
{catalogs.trainingTypes.map((t) => (
|
||||
<option key={t.id} value={t.id}>
|
||||
{t.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
onChange={(v) => setFilters({ ...filters, training_type_id: v })}
|
||||
options={trainingTypeOptions}
|
||||
allLabel="Alle Trainingsstile"
|
||||
filterPlaceholder="Trainingsstil filtern…"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="form-label">Zielgruppe</label>
|
||||
<select
|
||||
className="form-input"
|
||||
<SearchableSelect
|
||||
value={filters.target_group_id}
|
||||
onChange={(e) => setFilters({ ...filters, target_group_id: e.target.value })}
|
||||
>
|
||||
<option value="">Alle</option>
|
||||
{catalogs.targetGroups.map((g) => (
|
||||
<option key={g.id} value={g.id}>
|
||||
{g.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
onChange={(v) => setFilters({ ...filters, target_group_id: v })}
|
||||
options={targetGroupOptions}
|
||||
allLabel="Alle Zielgruppen"
|
||||
filterPlaceholder="Zielgruppe filtern…"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="form-label">Fähigkeit</label>
|
||||
<select
|
||||
className="form-input"
|
||||
<SearchableSelect
|
||||
value={filters.skill_id}
|
||||
onChange={(e) => setFilters({ ...filters, skill_id: e.target.value })}
|
||||
>
|
||||
<option value="">Alle</option>
|
||||
{catalogs.skills.map((s) => (
|
||||
<option key={s.id} value={s.id}>
|
||||
{s.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
onChange={(v) => setFilters({ ...filters, skill_id: v })}
|
||||
options={skillOptions}
|
||||
allLabel="Alle Fähigkeiten"
|
||||
filterPlaceholder="Fähigkeit filtern…"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="form-label">Fähigkeit Stufe von</label>
|
||||
<select
|
||||
className="form-input"
|
||||
<SearchableSelect
|
||||
value={filters.skill_min_level}
|
||||
onChange={(e) => setFilters({ ...filters, skill_min_level: e.target.value })}
|
||||
>
|
||||
<option value="">egal</option>
|
||||
{LEVEL_FILTER_OPTS.map((o) => (
|
||||
<option key={o.value} value={String(o.level)}>
|
||||
{o.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
onChange={(v) => setFilters({ ...filters, skill_min_level: v })}
|
||||
options={levelFilterOptions}
|
||||
allLabel="egal (min)"
|
||||
filterPlaceholder="Stufe suchen…"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="form-label">Fähigkeit Stufe bis</label>
|
||||
<select
|
||||
className="form-input"
|
||||
<SearchableSelect
|
||||
value={filters.skill_max_level}
|
||||
onChange={(e) => setFilters({ ...filters, skill_max_level: e.target.value })}
|
||||
>
|
||||
<option value="">egal</option>
|
||||
{LEVEL_FILTER_OPTS.map((o) => (
|
||||
<option key={`m-${o.value}`} value={String(o.level)}>
|
||||
{o.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
onChange={(v) => setFilters({ ...filters, skill_max_level: v })}
|
||||
options={levelFilterOptions}
|
||||
allLabel="egal (max)"
|
||||
filterPlaceholder="Stufe suchen…"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="form-label">Sichtbarkeit</label>
|
||||
<select
|
||||
className="form-input"
|
||||
<SearchableSelect
|
||||
value={filters.visibility}
|
||||
onChange={(e) => setFilters({ ...filters, visibility: e.target.value })}
|
||||
>
|
||||
<option value="">Alle</option>
|
||||
<option value="private">Privat</option>
|
||||
<option value="club">Verein</option>
|
||||
<option value="official">Offiziell</option>
|
||||
</select>
|
||||
onChange={(v) => setFilters({ ...filters, visibility: v })}
|
||||
options={visibilityOptions}
|
||||
allLabel="Alle"
|
||||
filterPlaceholder="Filtern…"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="form-label">Status</label>
|
||||
<select
|
||||
className="form-input"
|
||||
<SearchableSelect
|
||||
value={filters.status}
|
||||
onChange={(e) => setFilters({ ...filters, status: e.target.value })}
|
||||
>
|
||||
<option value="">Alle</option>
|
||||
<option value="draft">Entwurf</option>
|
||||
<option value="in_review">In Prüfung</option>
|
||||
<option value="approved">Freigegeben</option>
|
||||
<option value="archived">Archiviert</option>
|
||||
</select>
|
||||
onChange={(v) => setFilters({ ...filters, status: v })}
|
||||
options={statusOptions}
|
||||
allLabel="Alle"
|
||||
filterPlaceholder="Filtern…"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in new issue
Block a user