- Renomear /relatorios/categorias para /relatorios/tendencias - Renomear /relatorios/cartoes para /relatorios/uso-cartoes - Criar componente CategoryIconBadge unificado com cores dinâmicas - Atualizar cards de categorias com novo layout (ações no footer) - Atualizar cards de orçamentos com CategoryIconBadge - Adicionar tooltip detalhado nas células de tendências (valor anterior e diferença) - Adicionar dot colorido (verde/vermelho) para indicar tipo de categoria Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
98 lines
2.9 KiB
TypeScript
98 lines
2.9 KiB
TypeScript
"use client";
|
|
|
|
import { RiPieChartLine } from "@remixicon/react";
|
|
import { CategoryIconBadge } from "@/components/categorias/category-icon-badge";
|
|
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 { title_font } from "@/public/fonts/font_index";
|
|
|
|
type CardCategoryBreakdownProps = {
|
|
data: CardDetailData["categoryBreakdown"];
|
|
};
|
|
|
|
export function CardCategoryBreakdown({ data }: CardCategoryBreakdownProps) {
|
|
if (data.length === 0) {
|
|
return (
|
|
<Card className="h-full">
|
|
<CardHeader className="pb-3">
|
|
<CardTitle
|
|
className={`${title_font.className} flex items-center gap-1.5 text-base`}
|
|
>
|
|
<RiPieChartLine className="size-4 text-primary" />
|
|
Gastos por Categoria
|
|
</CardTitle>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<WidgetEmptyState
|
|
icon={<RiPieChartLine className="size-6 text-muted-foreground" />}
|
|
title="Nenhuma categoria encontrada"
|
|
description="Quando houver despesas categorizadas, elas aparecerão aqui."
|
|
/>
|
|
</CardContent>
|
|
</Card>
|
|
);
|
|
}
|
|
|
|
const _totalAmount = data.reduce((acc, c) => acc + c.amount, 0);
|
|
|
|
return (
|
|
<Card className="h-full">
|
|
<CardHeader className="pb-3">
|
|
<CardTitle
|
|
className={`${title_font.className} flex items-center gap-1.5 text-base`}
|
|
>
|
|
<RiPieChartLine className="size-4 text-primary" />
|
|
Gastos por Categoria
|
|
</CardTitle>
|
|
</CardHeader>
|
|
|
|
<CardContent className="pt-0">
|
|
<div className="flex flex-col">
|
|
{data.map((category, index) => (
|
|
<div
|
|
key={category.id}
|
|
className="flex flex-col py-2 border-b border-dashed last:border-0"
|
|
>
|
|
<div className="flex items-center justify-between gap-3">
|
|
<div className="flex min-w-0 flex-1 items-center gap-2">
|
|
<CategoryIconBadge
|
|
icon={category.icon}
|
|
name={category.name}
|
|
colorIndex={index}
|
|
/>
|
|
|
|
{/* Name and percentage */}
|
|
<div className="min-w-0 flex-1">
|
|
<span className="text-sm font-medium truncate block">
|
|
{category.name}
|
|
</span>
|
|
<span className="text-xs text-muted-foreground">
|
|
{category.percent.toFixed(0)}% do total
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Value */}
|
|
<div className="flex shrink-0 flex-col items-end">
|
|
<MoneyValues
|
|
className="text-foreground"
|
|
amount={category.amount}
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Progress bar */}
|
|
<div className="ml-11 mt-1.5">
|
|
<Progress className="h-1.5" value={category.percent} />
|
|
</div>
|
|
</div>
|
|
))}
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
);
|
|
}
|