'use client'; import { useEffect, useState } from 'react'; import { useSuperAdmin } from '../_lib/super-admin-context'; import { useRouter } from 'next/navigation'; import Link from 'next/link'; export default function AdminDashboard() { const { admin, loading } = useSuperAdmin(); const router = useRouter(); const [tenants, setTenants] = useState([]); const [bots, setBots] = useState([]); useEffect(() => { if (loading) return; if (!admin) { router.replace('/admin/login'); return; } fetch('/api/admin/tenants').then(r => r.ok && r.json()).then(d => setTenants(d ?? [])).catch(() => {}); fetch('/api/admin/bots').then(r => r.ok && r.json()).then(d => setBots(d ?? [])).catch(() => {}); }, [admin, loading, router]); if (loading) return

Loading...

; if (!admin) return null; const totalTenants = tenants.length; const activeTenants = tenants.filter((t: any) => t.isActive).length; const totalBots = bots.length; const totalMessages = tenants.reduce((s: number, t: any) => s + (t.stats?.messages ?? 0), 0); return (

Admin Dashboard

Tenants
{totalTenants}
{activeTenants} active
Bot Accounts
{totalBots}
in pool
Messages
{totalMessages}
Avg tenants/bot
{totalBots ? Math.round(totalTenants / totalBots) : 0}
Manage Tenants Manage Bots
); }