import { A } from '@solidjs/router'; import { createResource, createSignal, Show, For } from 'solid-js'; import { Eye, Pencil, Trash2 } from 'lucide-solid'; import AdminShell from '~/components/AdminShell'; const API = '/api/gateway'; type Role = { id: string; name: string; description?: string; code?: string; }; async function loadInternalRoles(): Promise { try { const res = await fetch(`${API}/api/admin/roles?audience=INTERNAL`); if (!res.ok) throw new Error('Failed to load'); const data = await res.json(); const rows = Array.isArray(data) ? data : (data.roles || []); return rows.map((r: any) => ({ id: r.id, name: r.name, description: r.description || '', code: r.code || r.key || '', })); } catch { return []; } } export default function InternalRolesPage() { const [roles, { refetch }] = createResource(loadInternalRoles); const [deleting, setDeleting] = createSignal(''); const [deleteError, setDeleteError] = createSignal(''); const handleDelete = async (id: string, name: string) => { if (!confirm(`Delete role "${name}"? This cannot be undone.`)) return; setDeleting(id); setDeleteError(''); try { const res = await fetch(`${API}/api/admin/roles/${id}`, { method: 'DELETE' }); if (!res.ok) throw new Error('Failed to delete role'); refetch(); } catch (err: any) { setDeleteError(err.message || 'Failed to delete role'); } finally { setDeleting(''); } }; return (
{/* ── Page header ── */}

Internal Role Management

Manage internal employee roles and permissions.

Create Internal Role
{/* ── Content ── */}
{deleteError()}
{(role) => ( )}
Name Description Actions
Loading internal roles…
Failed to load roles. Is the backend running?
No internal roles found. Create your first role.

{role.name}

{role.code || role.id?.slice(0, 8) || '—'}

{role.description || 'No description added yet.'}
); }