import { type MonthlyProjection } from '@/api'; import { formatAmount } from '@/lib/format'; import { cn } from '@/lib/utils'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '@/components/ui/table'; const MONTH_NAMES = [ '', 'Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic', ]; interface YearlyOverviewProps { months: MonthlyProjection[]; selectedMonth: number; onSelectMonth: (month: number) => void; } export default function YearlyOverview({ months, selectedMonth, onSelectMonth, }: YearlyOverviewProps) { const currentMonth = new Date().getMonth() + 1; const currentYear = new Date().getFullYear(); return (
Mes Ingresos Egresos Fijos Otros Gastos Gran Total Ahorro Balance {months.map((m) => { const isSelected = m.month === selectedMonth; const isCurrent = m.month === currentMonth && m.year === currentYear; return ( onSelectMonth(m.month)} > {MONTH_NAMES[m.month]} {isCurrent && ( )} {formatAmount(m.projected_income, 'CRC')} {formatAmount(m.projected_fixed_expenses, 'CRC')} {formatAmount(m.uncovered_actual, 'CRC')} {formatAmount(m.gran_total_egresos, 'CRC')} {formatAmount(m.projected_savings, 'CRC')} = 0 ? 'text-primary' : 'text-destructive', )} > {m.net_balance >= 0 ? '+' : ''} {formatAmount(m.net_balance, 'CRC')} ); })}
); }