import React, { useState, useEffect } from 'react'; import { Card } from '../ui/card'; import { Button } from '../ui/button'; import { StatCard } from '../dashboard/StatCard'; import { Users, DollarSign, Activity, AlertTriangle, HardDrive, ShoppingBag, ShieldAlert, CheckCircle, Loader2, } from 'lucide-react'; import { adminService } from '../../services/adminService'; import { Report } from '../../types'; import { useToast } from '../../context/ToastContext'; import { logger } from '@/utils/logger'; export const AdminDashboardView: React.FC = () => { const { addToast } = useToast(); const [stats, setStats] = useState({}); const [reports, setReports] = useState([]); const [uploads, setUploads] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { const fetchData = async () => { setLoading(true); try { const [statsData, reportsData, uploadsData] = await Promise.all([ adminService.getDashboardStats(), adminService.getModerationQueue('pending'), adminService.getRecentUploads(), ]); setStats(statsData); setReports(reportsData); setUploads(uploadsData); } catch (e) { logger.error('Error loading admin dashboard data', { error: e instanceof Error ? e.message : String(e), stack: e instanceof Error ? e.stack : undefined, }); } finally { setLoading(false); } }; fetchData(); }, []); const handleAction = async (id: string, action: string) => { await adminService.resolveReport(id, action); setReports(reports.filter((r) => r.id !== id)); addToast(`Report ${action}`, 'success'); }; if (loading) return (
); return (

SYSTEM OVERVIEW

{/* Stats Grid */}
} trend={stats.trends?.users} color="cyan" /> } trend={stats.trends?.revenue} color="gold" /> } trend={stats.trends?.sessions} color="lime" /> } trend={stats.trends?.reports} color="red" />
{/* Main Chart Area (Mock) */}

Traffic & Server Load

{' '} Traffic
CPU
{Array.from({ length: 40 }).map((_, i) => (
))}
{/* Quick Actions */}

Quick Actions

System Health

Database Healthy
Storage 65% Used
API Latency 45ms
{/* Recent Reports */}

Recent Reports

{reports.map((report) => (
{report.targetName}
{report.targetType} • {report.reason}
))} {reports.length === 0 && (
No pending reports.
)}
{/* Recent Uploads */}

Moderation Queue

{uploads.map((upload) => (
{upload.name}
{upload.user} • {upload.size}
))}
); };