import React, { useMemo } from 'react'; import { cn, fmt } from '@/lib/utils'; import { AlertCircle, CheckCircle2, Clock, TrendingUp } from 'lucide-react'; import { Settings2 } from 'lucide-react'; import { Button } from '@/components/ui/button'; const CARD_DEFS = { starting: { label: 'Starting', icon: TrendingUp, bar: 'from-slate-400 to-slate-300', glow: '', valueClass: 'text-foreground', activateWhen: () => true, }, paid: { label: 'Total Paid', icon: CheckCircle2, bar: 'from-emerald-500 to-emerald-300', glow: 'shadow-[0_4px_20px_rgba(16,185,129,0.15)]', borderActive: 'border-emerald-400/40', valueClass: 'text-emerald-500', activateWhen: (v) => v > 0, }, remaining: { label: 'Remaining', icon: Clock, bar: 'from-blue-400 to-indigo-300', glow: '', valueClass: 'text-foreground', activateWhen: () => true, }, overdue: { label: 'Overdue', icon: AlertCircle, bar: 'from-rose-500 to-orange-400', glow: 'shadow-[0_4px_20px_rgba(239,68,68,0.12)]', borderActive: 'border-red-400/40', valueClass: 'text-red-500', activateWhen: (v) => v > 0, }, }; export const SummaryCard = React.memo(function SummaryCard({ type, value, onEdit, hint }) { const def = useMemo(() => CARD_DEFS[type], [type]); const isActive = useMemo(() => def.activateWhen(value || 0), [def, value]); const Icon = useMemo(() => def.icon, [def]); return (
{def.label}
{type === 'starting' && onEdit && ( )}{fmt(value)}
{hint &&{hint}
}