'use client';
import { useEffect, useState, useCallback } from 'react';
import { AdminRoleGuard } from '@/components/admin-role-guard';
import { api } from '@/lib/api';
import { cn } from '@/lib/cn';
// ── Types ──────────────────────────────────────────────────────────────────────
interface UserDto {
id: string;
name: string;
email: string;
role: string;
banned: boolean;
banReason: string | null;
createdAt: string;
updatedAt: string;
}
interface UserListDto {
users: UserDto[];
total: number;
}
interface ServiceStatusDto {
status: 'ok' | 'error';
latencyMs?: number;
error?: string;
}
interface ProviderStatusDto {
id: string;
name: string;
available: boolean;
modelCount: number;
}
interface HealthStatusDto {
status: 'ok' | 'degraded' | 'error';
database: ServiceStatusDto;
cache: ServiceStatusDto;
agentPool: { activeSessions: number };
providers: ProviderStatusDto[];
checkedAt: string;
}
// ── Admin Page ─────────────────────────────────────────────────────────────────
export default function AdminPage(): React.ReactElement {
return (
Loading users...
; } if (error) { return ({error}
{users.length} user(s)
No users found
| Name / Email | Role | Status | Created | Actions |
|---|---|---|---|---|
|
{user.name}
{user.email}
|
{user.role} | {user.banned ? ( Banned ) : ( Active )} | {new Date(user.createdAt).toLocaleDateString()} |
|
Loading health status...
; } if (error) { return ({error}
Latency: {health.database.latencyMs}ms
)} {health.database.error &&{health.database.error}
}Latency: {health.cache.latencyMs}ms
)} {health.cache.error &&{health.cache.error}
}Active sessions: {health.agentPool.activeSessions}
No providers configured
) : (