import MoneyValues from "@/components/money-values"; import type { PaymentMethodsData } from "@/lib/dashboard/payments/payment-methods"; import { getPaymentMethodIcon } from "@/lib/utils/icons"; import { RiBankCardLine, RiMoneyDollarCircleLine } from "@remixicon/react"; import { Progress } from "../ui/progress"; import { WidgetEmptyState } from "../widget-empty-state"; type PaymentMethodsWidgetProps = { data: PaymentMethodsData; }; const ICON_WRAPPER_CLASS = "flex size-10 shrink-0 items-center justify-center rounded-lg bg-muted text-foreground"; const formatPercentage = (value: number) => new Intl.NumberFormat("pt-BR", { minimumFractionDigits: 0, maximumFractionDigits: 1, }).format(value); const resolveIcon = (paymentMethod: string | null | undefined) => { if (!paymentMethod) { return ; } const icon = getPaymentMethodIcon(paymentMethod); if (icon) { return icon; } return ; }; export function PaymentMethodsWidget({ data }: PaymentMethodsWidgetProps) { if (data.methods.length === 0) { return ( } title="Nenhuma despesa encontrada" description="Cadastre despesas para visualizar a distribuição por forma de pagamento." /> ); } return (
    {data.methods.map((method) => { const icon = resolveIcon(method.paymentMethod); const percentageLabel = formatPercentage(method.percentage); return (
  • {icon}

    {method.paymentMethod}

    {method.transactions}{" "} {method.transactions === 1 ? "lançamento" : "lançamentos"} {percentageLabel}%
  • ); })}
); }