import React from 'react'; import { Card, CardContent, Typography, Box, Switch, Table, TableBody, TableCell, TableHead, TableRow, Chip } from '@mui/material'; import type { ModerationRole } from './api'; import { updateModerationRole } from './api'; interface Props { roles: ModerationRole[]; onChanged: () => void; onError: (msg: string) => void; } const TOGGLE_FIELDS: Array = ['can_resolve', 'can_escalate', 'can_force_gold_brain', 'is_active']; export const RolesCard: React.FC = ({ roles, onChanged, onError }) => { const toggle = async (code: string, field: keyof ModerationRole, value: boolean) => { try { const res = await updateModerationRole(code, { [field]: value } as Partial); if (res.success) onChanged(); else onError(res.error ?? 'Update failed'); } catch (e) { onError((e as Error).message); } }; return ( Roles & Permissions Maps Keycloak realm roles to HIL actions. Toggle changes auto-sync to Redis. Role can_resolve can_escalate can_force_gold_brain active {roles.map((role) => ( {role.role_label} {TOGGLE_FIELDS.map((field) => ( toggle(role.role_code, field, e.target.checked)} size="small" /> ))} ))}
); };