'use client';
import AdminShell from '@/components/AdminShell';
import { api } from '@/lib/api';
import { useEffect, useState } from 'react';
import { Users, FileText, Shield, Scale, Flag, TrendingUp, TrendingDown, UserPlus } from 'lucide-react';
import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, LineChart, Line } from 'recharts';
function StatCard({ label, value, icon: Icon, sub, color }: { label: string; value: number | string; icon: any; sub?: string; color: string }) {
return (
{label}
{value}
{sub &&
{sub}
}
);
}
export default function DashboardPage() {
const [stats, setStats] = useState(null);
const [growth, setGrowth] = useState(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
Promise.all([api.getDashboardStats(), api.getGrowthStats(30)])
.then(([s, g]) => { setStats(s); setGrowth(g); })
.catch(() => {})
.finally(() => setLoading(false));
}, []);
return (
Dashboard
Overview of Sojorn platform activity
{loading ? (
{[...Array(8)].map((_, i) => (
))}
) : stats ? (
<>
{/* Charts */}
{growth && (
User Growth (30 days)
v.slice(5)} />
Post Activity (30 days)
v.slice(5)} />
)}
{/* Quick Actions */}
>
) : (
Failed to load dashboard data.
)}
);
}