// KAR-787 / R53: single source of truth for the German role labels shown in
// the admin user modals — replaces the duplicated hardcoded ALL_ROLES maps in
// create-user-modal.tsx and edit-user-modal.tsx. The role SET is loaded from
// the DB (so adding/removing a role there is reflected); these labels keep the
// display curated in German, with a fallback to the DB label, then the code.

import type { RoleCode } from './permissions-shared'

export const ROLE_LABELS: Record<RoleCode, string> = {
  masteradmin: 'Masteradmin',
  admin:       'Admin',
  consultant:  'Berater',
  readonly:    'Nur Lesen',
  extern:      'Extern',
}

export function roleLabel(code: string, dbLabel?: string | null): string {
  return ROLE_LABELS[code as RoleCode] ?? dbLabel ?? code
}
