- Updated capability level mappings in the backend to reflect new terminology (e.g., "einsteiger" to "basis" and "experte" to "optimierung"). - Refactored the exercise management logic to normalize skill levels using canonical slugs, improving consistency across the application. - Enhanced the ExercisesListPage with additional filtering options for style direction, training type, and target group, along with AI search capabilities. - Incremented application version to 0.7.7 and updated changelog to document these changes.
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
/** Kanonische Übungs-Fähigkeitsstufen 1–5 (Slug → Anzeige) */
|
||
export const SKILL_LEVEL_OPTIONS = [
|
||
{ value: '', label: '—', level: null },
|
||
{ value: 'basis', label: '1 · Basis', level: 1 },
|
||
{ value: 'grundlagen', label: '2 · Grundlagen', level: 2 },
|
||
{ value: 'aufbau', label: '3 · Aufbau', level: 3 },
|
||
{ value: 'fortgeschritten', label: '4 · Fortgeschritten', level: 4 },
|
||
{ value: 'optimierung', label: '5 · Optimierung', level: 5 },
|
||
]
|
||
|
||
const LEGACY_MAP = {
|
||
einsteiger: 'basis',
|
||
experte: 'optimierung',
|
||
'1': 'basis',
|
||
'2': 'grundlagen',
|
||
'3': 'aufbau',
|
||
'4': 'fortgeschritten',
|
||
'5': 'optimierung',
|
||
}
|
||
|
||
const LABEL_BY_SLUG = Object.fromEntries(
|
||
SKILL_LEVEL_OPTIONS.filter((o) => o.value).map((o) => [o.value, o.label])
|
||
)
|
||
|
||
export function normalizeSkillLevelSlug(raw) {
|
||
if (raw == null || raw === '') return ''
|
||
const s = String(raw).trim().toLowerCase()
|
||
if (LEGACY_MAP[s]) return LEGACY_MAP[s]
|
||
if (LABEL_BY_SLUG[s]) return s
|
||
return ''
|
||
}
|
||
|
||
export function formatSkillLevelSlug(raw) {
|
||
const slug = normalizeSkillLevelSlug(raw)
|
||
if (!slug) return ''
|
||
return LABEL_BY_SLUG[slug] || slug
|
||
}
|