From 5a7b55e7932642582c8e9f28c9ffecdb61aeeaf1 Mon Sep 17 00:00:00 2001 From: Administrator Date: Fri, 10 Jul 2026 14:37:34 -0500 Subject: [PATCH] Actualizar frontend/src/pages/Cobranza.jsx --- frontend/src/pages/Cobranza.jsx | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/frontend/src/pages/Cobranza.jsx b/frontend/src/pages/Cobranza.jsx index d7b5d40..a77422b 100644 --- a/frontend/src/pages/Cobranza.jsx +++ b/frontend/src/pages/Cobranza.jsx @@ -4,6 +4,7 @@ import { api } from "../lib/api"; import { Loader, ErrorBox, Filters, Select, colorSemaforo } from "../components/UI"; import Modal from "../components/Modal"; import { useColumnasAjustables } from "../lib/useColumnasAjustables"; +import { setVistaActual, onRefrescar } from "../lib/vistaActual"; const MESES = ["ENERO","FEBRERO","MARZO","ABRIL","MAYO","JUNIO","JULIO","AGOSTO","SEPTIEMBRE","OCTUBRE","NOVIEMBRE","DICIEMBRE"]; const ANOS = [2024, 2025, 2026]; @@ -68,16 +69,21 @@ export default function Cobranza() { useEffect(() => { let activo = true; - setLoading(true); setError(null); - api.cobranza(ano, mes, sectorista, agrupacion) - .then((res) => { - if (!activo) return; - setFilas(res.filas || []); - setSectoristas(res.sectoristas || ["TODOS"]); - setLoading(false); - }) - .catch((e) => { if (activo) { setError(e.message); setLoading(false); } }); - return () => { activo = false; }; + setVistaActual(`cobranza:${ano}|${mes}|${sectorista}|${agrupacion}`); + const cargar = () => { + setLoading(true); setError(null); + api.cobranza(ano, mes, sectorista, agrupacion) + .then((res) => { + if (!activo) return; + setFilas(res.filas || []); + setSectoristas(res.sectoristas || ["TODOS"]); + setLoading(false); + }) + .catch((e) => { if (activo) { setError(e.message); setLoading(false); } }); + }; + cargar(); + const off = onRefrescar(cargar); + return () => { activo = false; off(); }; }, [ano, mes, agrupacion, sectorista]); // Cargar TODOS los alumnos una sola vez (para exportar y buscar) — 1 consulta cacheada