interface StatCard { label: string; value: string; sub: { type: "trend" | "stable"; text: string; color?: string }; icon: string; iconBg: string; iconColor: string; } interface ServiceStatsCardsProps { totalSent: number; successRate: number; deviceCount: number; todaySent: number; sentChangeRate?: number; successRateChange?: number; deviceCountChange?: number; todaySentChangeRate?: number; } export default function ServiceStatsCards({ totalSent, successRate, deviceCount, todaySent, sentChangeRate = 0, successRateChange = 0, deviceCountChange = 0, todaySentChangeRate = 0, }: ServiceStatsCardsProps) { const noChange: StatCard["sub"] = { type: "stable", text: "변동 없음" }; const cards: StatCard[] = [ { label: "총 발송 수", value: totalSent.toLocaleString(), sub: sentChangeRate === 0 ? noChange : sentChangeRate > 0 ? { type: "trend", text: `+${sentChangeRate.toLocaleString()}`, color: "text-indigo-600" } : { type: "trend", text: `${sentChangeRate.toLocaleString()}`, color: "text-red-500" }, icon: "equalizer", iconBg: "bg-indigo-50", iconColor: "text-indigo-600", }, { label: "성공률", value: `${successRate}%`, sub: successRateChange === 0 ? noChange : successRateChange > 0 ? { type: "trend", text: `+${successRateChange.toFixed(1)}%`, color: "text-emerald-600" } : { type: "trend", text: `${successRateChange.toFixed(1)}%`, color: "text-red-500" }, icon: "check_circle", iconBg: "bg-emerald-50", iconColor: "text-emerald-600", }, { label: "등록 기기 수", value: deviceCount.toLocaleString(), sub: deviceCountChange === 0 ? noChange : deviceCountChange > 0 ? { type: "trend", text: `+${deviceCountChange.toLocaleString()} today`, color: "text-amber-600" } : { type: "trend", text: `${deviceCountChange.toLocaleString()} today`, color: "text-red-500" }, icon: "devices", iconBg: "bg-amber-50", iconColor: "text-amber-600", }, { label: "오늘 발송", value: todaySent.toLocaleString(), sub: todaySentChangeRate === 0 ? noChange : todaySentChangeRate > 0 ? { type: "trend", text: `+${todaySentChangeRate.toLocaleString()}`, color: "text-[#2563EB]" } : { type: "trend", text: `${todaySentChangeRate.toLocaleString()}`, color: "text-red-500" }, icon: "today", iconBg: "bg-[#2563EB]/5", iconColor: "text-[#2563EB]", }, ]; return (
{cards.map((card) => (

{card.label}

{card.value}

{card.sub.type === "trend" && (

{card.sub.text.startsWith("-") ? "trending_down" : "trending_up"} {card.sub.text}

)} {card.sub.type === "stable" && (

{card.sub.text}

)}
{card.icon}
))}
); }