/** * Admin dashboard page. * URL: /admin * Shows community statistics and recent activity. * @see specs/prd-web.md Section M11 */ 'use client' import { useState, useEffect, useCallback } from 'react' import { ChatCircle, Users, FolderSimple, WarningCircle, TrendUp } from '@phosphor-icons/react' import { AdminLayout } from '@/components/admin/admin-layout' import { ErrorAlert } from '@/components/error-alert' import { getCommunityStats } from '@/lib/api/client' import type { CommunityStats } from '@/lib/api/types' import { useAuth } from '@/hooks/use-auth' import { PluginSlot } from '@/components/plugin-slot' interface StatCardProps { label: string value: number recentValue: number icon: typeof ChatCircle } function StatCard({ label, value, recentValue, icon: Icon }: StatCardProps) { return (
{recentValue > 0 && ( )}

{value}

{label}

) } export default function AdminDashboardPage() { const { getAccessToken } = useAuth() const [stats, setStats] = useState(null) const [loading, setLoading] = useState(true) const [error, setError] = useState(null) const fetchStats = useCallback(async () => { setError(null) try { const data = await getCommunityStats(getAccessToken() ?? '') setStats(data) } catch { setError('Failed to load dashboard statistics. The API may be unreachable.') } finally { setLoading(false) } }, [getAccessToken]) useEffect(() => { void fetchStats() }, [fetchStats]) return (

Dashboard

{loading &&

Loading statistics...

} {error && void fetchStats()} />} {stats && (
)}
) }