shinkan-jinkendo/frontend/src/constants/skillLevels.js
Lars 76098f5244
Some checks failed
Deploy Development / deploy (push) Successful in 36s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 5s
Test Suite / playwright-tests (push) Failing after 1m55s
feat: update capability levels and enhance exercise filtering
- 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.
2026-04-27 18:25:23 +02:00

38 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/** Kanonische Übungs-Fähigkeitsstufen 15 (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
}