"use client"; import MoneyValues from "@/components/money-values"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Progress } from "@/components/ui/progress"; import { WidgetEmptyState } from "@/components/widget-empty-state"; import type { CardDetailData } from "@/lib/relatorios/cartoes-report"; import { buildCategoryInitials, getCategoryBgColor, getCategoryColor, } from "@/lib/utils/category-colors"; import { getIconComponent } from "@/lib/utils/icons"; import { title_font } from "@/public/fonts/font_index"; import { RiPieChartLine } from "@remixicon/react"; type CardCategoryBreakdownProps = { data: CardDetailData["categoryBreakdown"]; }; export function CardCategoryBreakdown({ data }: CardCategoryBreakdownProps) { if (data.length === 0) { return ( Gastos por Categoria } title="Nenhuma categoria encontrada" description="Quando houver despesas categorizadas, elas aparecerão aqui." /> ); } const totalAmount = data.reduce((acc, c) => acc + c.amount, 0); return ( Gastos por Categoria
{data.map((category, index) => { const IconComponent = category.icon ? getIconComponent(category.icon) : null; const color = getCategoryColor(index); const bgColor = getCategoryBgColor(index); const initials = buildCategoryInitials(category.name); return (
{IconComponent ? ( ) : ( {initials} )}
{/* Name and percentage */}
{category.name} {category.percent.toFixed(0)}% do total
{/* Value */}
{/* Progress bar */}
); })}
); }