import { TrendingUp, TrendingDown } from 'lucide-react'; import { Badge } from '@/components/ui/badge'; import { Card, CardHeader, CardTitle, CardDescription, CardAction, CardFooter } from '@/components/ui/card'; import { formatCurrency, formatNumber } from '@/lib/formatters'; import { cn } from '@/lib/utils'; import type { StatItem } from '@/types'; export interface StatCardProps { title: string; stat: StatItem; isCurrency?: boolean; isPercentage?: boolean; className?: string; } export function StatCard({ title, stat, isCurrency = true, isPercentage = false, className }: StatCardProps) { const hasComparison = stat.yesterday !== null; const isPositive = stat.change !== null && stat.change >= 0; return (
{title}
{isPercentage ? `${stat.value}%` : (isCurrency ? formatCurrency(stat.value) : formatNumber(stat.value))} {hasComparison && ( {isPositive ? : } {stat.change === null ? '∞' : `${Math.abs(stat.change)}%`} )}
{hasComparison && (
Kemarin: {isPercentage ? `${stat.yesterday}%` : (isCurrency ? formatCurrency(stat.yesterday) : formatNumber(stat.yesterday))}
)}
); }