Actualizar frontend/src/pages/Cobranza.jsx
This commit is contained in:
@@ -4,6 +4,7 @@ import { api } from "../lib/api";
|
|||||||
import { Loader, ErrorBox, Filters, Select, colorSemaforo } from "../components/UI";
|
import { Loader, ErrorBox, Filters, Select, colorSemaforo } from "../components/UI";
|
||||||
import Modal from "../components/Modal";
|
import Modal from "../components/Modal";
|
||||||
import { useColumnasAjustables } from "../lib/useColumnasAjustables";
|
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 MESES = ["ENERO","FEBRERO","MARZO","ABRIL","MAYO","JUNIO","JULIO","AGOSTO","SEPTIEMBRE","OCTUBRE","NOVIEMBRE","DICIEMBRE"];
|
||||||
const ANOS = [2024, 2025, 2026];
|
const ANOS = [2024, 2025, 2026];
|
||||||
@@ -68,6 +69,8 @@ export default function Cobranza() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let activo = true;
|
let activo = true;
|
||||||
|
setVistaActual(`cobranza:${ano}|${mes}|${sectorista}|${agrupacion}`);
|
||||||
|
const cargar = () => {
|
||||||
setLoading(true); setError(null);
|
setLoading(true); setError(null);
|
||||||
api.cobranza(ano, mes, sectorista, agrupacion)
|
api.cobranza(ano, mes, sectorista, agrupacion)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@@ -77,7 +80,10 @@ export default function Cobranza() {
|
|||||||
setLoading(false);
|
setLoading(false);
|
||||||
})
|
})
|
||||||
.catch((e) => { if (activo) { setError(e.message); setLoading(false); } });
|
.catch((e) => { if (activo) { setError(e.message); setLoading(false); } });
|
||||||
return () => { activo = false; };
|
};
|
||||||
|
cargar();
|
||||||
|
const off = onRefrescar(cargar);
|
||||||
|
return () => { activo = false; off(); };
|
||||||
}, [ano, mes, agrupacion, sectorista]);
|
}, [ano, mes, agrupacion, sectorista]);
|
||||||
|
|
||||||
// Cargar TODOS los alumnos una sola vez (para exportar y buscar) — 1 consulta cacheada
|
// Cargar TODOS los alumnos una sola vez (para exportar y buscar) — 1 consulta cacheada
|
||||||
|
|||||||
Reference in New Issue
Block a user