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
|
|||
|
|
}
|