From 99d0c4ebd76d5c683ff846cb5bce6361da1c0c08 Mon Sep 17 00:00:00 2001 From: Carlos Escalante Date: Mon, 30 Mar 2026 11:14:43 -0600 Subject: [PATCH] Split budget Resumen into Detalle, Transacciones, and Proyecciones sub-tabs Reduces scrolling by organizing the budget overview into three inner tabs. Clicking a month in the yearly table auto-switches to the Detalle tab. Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/src/pages/Budget.tsx | 197 ++++++++++++++++++---------------- 1 file changed, 106 insertions(+), 91 deletions(-) diff --git a/frontend/src/pages/Budget.tsx b/frontend/src/pages/Budget.tsx index a0a971c..b25136a 100644 --- a/frontend/src/pages/Budget.tsx +++ b/frontend/src/pages/Budget.tsx @@ -36,6 +36,8 @@ export default function Budget() { refresh, } = useBudget(currentYear); + const [subTab, setSubTab] = useState<'detail' | 'transactions' | 'projections'>('detail'); + // Transaction list state for the selected month const [transactions, setTransactions] = useState([]); const [txLoading, setTxLoading] = useState(false); @@ -95,100 +97,113 @@ export default function Budget() { Items Recurrentes - - {/* Annual Summary */} - {projection && ( -
- - -

Ingresos Anuales

-

- {formatAmount(projection.annual_income, 'CRC')} -

-
-
- - -

Egresos Anuales

-

- {formatAmount(projection.annual_expenses, 'CRC')} -

-
-
- - -

Ahorro Anual

-

- {formatAmount(projection.annual_savings, 'CRC')} -

-
-
- - -

Balance Neto Anual

-

= 0 ? 'text-primary' : 'text-destructive', - )} - > - {projection.annual_net >= 0 ? '+' : ''} - {formatAmount(projection.annual_net, 'CRC')} -

-
-
-
- )} + + setSubTab(v as typeof subTab)} + > + + + Detalle: {MONTH_NAMES[selectedMonth]} {year} + + Transacciones + Proyecciones + - {/* Yearly Overview Table */} - {loading ? ( -
- -
- ) : projection ? ( - - - - - - ) : null} + + {monthDetail && } + - {/* Monthly Detail */} - {monthDetail && } + + setTxSource(v as typeof txSource)} + > + + Tarjeta + Efectivo + Transferencias + + + { + fetchTransactions(); + refresh(); + }} + showCategory={txSource === 'CREDIT_CARD'} + emptyMessage={`Sin transacciones de ${txSource === 'CREDIT_CARD' ? 'tarjeta' : txSource === 'CASH' ? 'efectivo' : 'transferencia'} en ${MONTH_NAMES[selectedMonth]}`} + /> + - {/* Transactions for selected month */} -
-

- Transacciones — {MONTH_NAMES[selectedMonth]} {year} -

- setTxSource(v as typeof txSource)} - > - - Tarjeta - Efectivo - Transferencias - - - { - fetchTransactions(); - refresh(); - }} - showCategory={txSource === 'CREDIT_CARD'} - emptyMessage={`Sin transacciones de ${txSource === 'CREDIT_CARD' ? 'tarjeta' : txSource === 'CASH' ? 'efectivo' : 'transferencia'} en ${MONTH_NAMES[selectedMonth]}`} - /> -
+ + {projection && ( +
+ + +

Ingresos Anuales

+

+ {formatAmount(projection.annual_income, 'CRC')} +

+
+
+ + +

Egresos Anuales

+

+ {formatAmount(projection.annual_expenses, 'CRC')} +

+
+
+ + +

Ahorro Anual

+

+ {formatAmount(projection.annual_savings, 'CRC')} +

+
+
+ + +

Balance Neto Anual

+

= 0 ? 'text-primary' : 'text-destructive', + )} + > + {projection.annual_net >= 0 ? '+' : ''} + {formatAmount(projection.annual_net, 'CRC')} +

+
+
+
+ )} + + {loading ? ( +
+ +
+ ) : projection ? ( + + + { + setSelectedMonth(m); + setSubTab('detail'); + }} + /> + + + ) : null} +
+