UNPKG

analytica-frontend-lib

Version:

Repositório público dos componentes utilizados nas plataformas da Analytica Ensino

1 lines 2.55 kB
{"version":3,"sources":["../src/types/profileLabels.ts"],"sourcesContent":["/**\n * Profile labels (nomenclatura) types\n *\n * Some institutions rename the default profiles (e.g. Aluno -> Estudante,\n * Gestor Unidade -> Diretor(a)/Pedagogo(a)). Those overrides are stored in a\n * per-institution PROFILE_LABELS feature flag and consumed here so the apps can\n * render the institution's preferred nomenclatura.\n */\n\nimport { PROFILE_ROLES } from './chat';\n\n/**\n * Map of canonical profile role -> custom display label (nomenclatura).\n * Mirrors the backend PROFILE_LABELS feature flag `version`. Any role may be\n * omitted, in which case the default label applies.\n */\nexport type ProfileLabelsMap = Partial<Record<PROFILE_ROLES, string>>;\n\n/**\n * Default profile labels — mirror the seeded `profiles.description` values on\n * the backend. Used as the fallback baseline when an institution has no\n * PROFILE_LABELS feature flag (or omits a given role).\n */\nexport const DEFAULT_PROFILE_LABELS: Record<PROFILE_ROLES, string> = {\n [PROFILE_ROLES.SUPER_ADMIN]: 'Super Admin',\n [PROFILE_ROLES.GENERAL_MANAGER]: 'Gestor Geral',\n [PROFILE_ROLES.REGIONAL_MANAGER]: 'Gestor Regional',\n [PROFILE_ROLES.UNIT_MANAGER]: 'Gestor de Unidade',\n [PROFILE_ROLES.TEACHER]: 'Professor',\n [PROFILE_ROLES.STUDENT]: 'Aluno',\n};\n\n/**\n * Resolve the display label for a profile role, preferring the institution's\n * custom nomenclatura and falling back to the default. Unknown roles return the\n * raw value so callers never render `undefined`.\n *\n * @param role - Canonical profile role (e.g. PROFILE_ROLES.STUDENT)\n * @param labels - Optional custom label map (from the PROFILE_LABELS flag)\n * @returns The display label to render\n */\nexport const getProfileLabel = (\n role: PROFILE_ROLES | string,\n labels?: ProfileLabelsMap | null\n): string => {\n return (\n labels?.[role as PROFILE_ROLES] ||\n DEFAULT_PROFILE_LABELS[role as PROFILE_ROLES] ||\n String(role)\n );\n};\n\n/**\n * Shape of the PROFILE_LABELS feature flag record returned by\n * `GET /featureFlags/institution/:id/page/PROFILE_LABELS`.\n */\nexport interface ProfileLabelsFeatureFlag {\n institutionId: string;\n page: string;\n version: ProfileLabelsMap;\n}\n"],"mappings":";AAuBO,IAAM,yBAAwD;AAAA,EACnE,gCAA0B,GAAG;AAAA,EAC7B,wCAA8B,GAAG;AAAA,EACjC,0CAA+B,GAAG;AAAA,EAClC,kCAA2B,GAAG;AAAA,EAC9B,wBAAsB,GAAG;AAAA,EACzB,wBAAsB,GAAG;AAC3B;AAWO,IAAM,kBAAkB,CAC7B,MACA,WACW;AACX,SACE,SAAS,IAAqB,KAC9B,uBAAuB,IAAqB,KAC5C,OAAO,IAAI;AAEf;","names":[]}