diff --git a/frontend/src/pages/SettingsRechte.tsx b/frontend/src/pages/SettingsRechte.tsx index 79977df..936d423 100644 --- a/frontend/src/pages/SettingsRechte.tsx +++ b/frontend/src/pages/SettingsRechte.tsx @@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next'; import { SettingsRolesPage } from './SettingsRoles'; import { SettingsGroupsPage } from './SettingsGroups'; import { useAllEntityPermissions, useEntityRegistry } from '@/api/entityPermissionHooks'; +import { type EntityPermission, type EntityRegistryEntry } from '@/api/entityPermissions'; import { useAuditLog, type AuditLogEntry } from '@/api/audit'; import { usePermission } from '@/hooks/usePermission'; import { Table, type TableColumn } from '@/components/ui/Table'; @@ -19,25 +20,14 @@ import { apiDelete } from '@/api/client'; import { Search, Trash2, Shield, Users, Share2, History } from 'lucide-react'; import clsx from 'clsx'; -// ─── Types ───────────────────────────────────────────────────────────────── +// ─── Helpers ──────────────────────────────────────────────────────────────── -interface EntityPermission { - id: string; - entity_type: string; - entity_id: string; - principal_type: string; - principal_id: string; - principal_name: string | null; - permission_level: string; - expires_at: string | null; - created_by: string | null; - created_at: string | null; +function getPrincipalName(p: EntityPermission): string | null { + return p.principal_type === 'user' ? p.user_name : p.group_name; } -interface EntityRegistryEntry { - entity_type: string; - display_name: string; - description: string | null; +function getPrincipalId(p: EntityPermission): string | null { + return p.principal_type === 'user' ? p.user_id : p.group_id; } // ─── Permission Level Badge ──────────────────────────────────────────────── @@ -129,9 +119,12 @@ function FreigabenTab() { if (filterPrincipal) { const q = filterPrincipal.toLowerCase(); items = items.filter( - (p) => - (p.principal_name && p.principal_name.toLowerCase().includes(q)) || - p.principal_id.toLowerCase().includes(q) + (p) => { + const name = getPrincipalName(p); + const id = getPrincipalId(p); + return (name && name.toLowerCase().includes(q)) || + (id && id.toLowerCase().includes(q)); + } ); } return items; @@ -162,12 +155,16 @@ function FreigabenTab() { { key: 'principal_type', header: 'Principal', - render: (row) => ( -