'use client'; import { useEffect, useState } from 'react'; interface Stats { totalMembers: number; totalOrders: number; totalRevenue: number; pendingContacts: number; activeSubscribers: number; monthlyChart: Array<{ month: string; revenue: number }>; } function StatCard({ label, value, icon, color }: { label: string; value: string; icon: React.ReactNode; color: string }) { return (
{label}
{icon}

{value}

); } export default function AdminDashboard() { const [stats, setStats] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { fetch('/api/admin/stats') .then((r) => r.json()) .then((d) => setStats(d)) .catch(console.error) .finally(() => setLoading(false)); }, []); const maxRevenue = stats ? Math.max(...stats.monthlyChart.map((m) => m.revenue), 1) : 1; return (
{/* 헤더 */}

대시보드

쟁승메이드 운영 현황

{loading ? (
) : ( <> {/* 통계 카드 */}
} /> } /> } /> } /> } />
{/* 월별 수익 차트 */}

월별 수익 현황 (최근 6개월)

{stats?.monthlyChart.map((item) => { const height = maxRevenue > 0 ? Math.max((item.revenue / maxRevenue) * 100, item.revenue > 0 ? 4 : 0) : 0; const monthLabel = item.month.slice(5); // MM return (
{item.revenue > 0 ? `₩${(item.revenue / 1000).toFixed(0)}K` : ''}
0 ? '4px' : '0' }} />
{monthLabel}월
); })}
{(stats?.totalRevenue ?? 0) === 0 && (

결제 데이터가 없습니다

)}
)}
); }