"use client"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import type { CardDetailData } from "@/lib/relatorios/cartoes-report"; import { getIconComponent } from "@/lib/utils/icons"; import { RiPieChartLine } from "@remixicon/react"; type CardCategoryBreakdownProps = { data: CardDetailData["categoryBreakdown"]; }; const COLORS = [ "#ef4444", "#3b82f6", "#10b981", "#f59e0b", "#8b5cf6", "#ec4899", "#14b8a6", "#f97316", "#6366f1", "#84cc16", ]; export function CardCategoryBreakdown({ data }: CardCategoryBreakdownProps) { const formatCurrency = (value: number) => { return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL", minimumFractionDigits: 2, maximumFractionDigits: 2, }).format(value); }; if (data.length === 0) { return ( Gastos por Categoria Nenhum gasto neste perĂodo ); } return ( Gastos por Categoria {data.map((category, index) => { const IconComponent = category.icon ? getIconComponent(category.icon) : null; const color = COLORS[index % COLORS.length]; return ( {IconComponent ? ( ) : ( )} {category.name} {formatCurrency(category.amount)} {category.percent.toFixed(0)}% ); })} ); }
Nenhum gasto neste perĂodo