import { Badge } from '@/components/ui/badge'; import { Card, CardDescription, CardFooter, CardHeader, CardTitle, CardAction, } from '@/components/ui/card'; import { formatCurrency, formatNumber } from '@/lib/formatters'; import { cn } from '@/lib/utils'; import type { StatItem } from '@/types'; import { TrendingDown, TrendingUp } from 'lucide-react'; 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} {hasComparison && ( {isPositive ? ( ) : ( )} {stat.change === null ? '∞' : `${Math.abs(stat.change)}%`} )}
{isPercentage ? `${stat.value}%` : isCurrency ? formatCurrency(stat.value) : formatNumber(stat.value)}
{hasComparison && (
Kemarin:{' '} {isPercentage ? `${stat.yesterday}%` : isCurrency ? formatCurrency(stat.yesterday) : formatNumber(stat.yesterday)}
)}
); }