import { RiCheckboxCircleFill } from "@remixicon/react"; import Link from "next/link"; import { buildBillStatusLabel, buildBillWidgetStatusLabel, formatBillWidgetOverdueLabel, isBillOverdue, isIncomeBill, } from "@/features/dashboard/bills/bills-helpers"; import type { DashboardBill } from "@/features/dashboard/bills/bills-queries"; import { dashboardWidgetListStyles as styles } from "@/features/dashboard/components/dashboard-widget-list-styles"; import { EstablishmentLogo } from "@/shared/components/entity-avatar"; import MoneyValues from "@/shared/components/money-values"; import { Button } from "@/shared/components/ui/button"; import { Tooltip, TooltipContent, TooltipTrigger, } from "@/shared/components/ui/tooltip"; import { formatPeriodForUrl, getCurrentPeriod } from "@/shared/utils/period"; import { cn } from "@/shared/utils/ui"; type BillListItemProps = { bill: DashboardBill; period?: string; onPay: (billId: string) => void; }; function buildTransactionsHref(name: string, period?: string): string { const params = new URLSearchParams({ q: name }); const current = getCurrentPeriod(); if (period && period !== current) { params.set("periodo", formatPeriodForUrl(period)); } return `/transactions?${params.toString()}`; } export function BillListItem({ bill, period, onPay }: BillListItemProps) { const statusLabel = buildBillWidgetStatusLabel(bill); const absoluteStatusLabel = buildBillStatusLabel(bill); const overdue = isBillOverdue(bill); const income = isIncomeBill(bill); const overdueLabel = formatBillWidgetOverdueLabel(bill); const statusTooltipLabel = overdueLabel || (statusLabel && statusLabel !== absoluteStatusLabel) ? absoluteStatusLabel : null; const href = buildTransactionsHref(bill.name, period); return (