Actualizar frontend/src/pages/Rentabilidad.jsx
This commit is contained in:
@@ -4,6 +4,7 @@ import { api } from "../lib/api";
|
|||||||
import { Loader, ErrorBox, Filters, Select } from "../components/UI";
|
import { Loader, ErrorBox, Filters, Select } 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];
|
||||||
@@ -44,11 +45,16 @@ export default function Rentabilidad() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let activo = true;
|
let activo = true;
|
||||||
|
setVistaActual(`rentabilidad:${ano}|${mes}|${sede}|${programa}`);
|
||||||
|
const cargarSeguro = () => {
|
||||||
setLoading(true); setError(null);
|
setLoading(true); setError(null);
|
||||||
api.rentabilidad(ano, mes, sede, programa)
|
api.rentabilidad(ano, mes, sede, programa)
|
||||||
.then((res) => { if (activo) { setFilas(res.filas || []); setLoading(false); } })
|
.then((res) => { if (activo) { setFilas(res.filas || []); setLoading(false); } })
|
||||||
.catch((e) => { if (activo) { setError(e.message); setLoading(false); } });
|
.catch((e) => { if (activo) { setError(e.message); setLoading(false); } });
|
||||||
return () => { activo = false; };
|
};
|
||||||
|
cargarSeguro();
|
||||||
|
const off = onRefrescar(cargarSeguro);
|
||||||
|
return () => { activo = false; off(); };
|
||||||
}, [ano, mes, sede, programa]);
|
}, [ano, mes, sede, programa]);
|
||||||
|
|
||||||
const datos = useMemo(() => filas.filter((f)=>String(f[0]).toUpperCase()!=="TOTAL GENERAL"), [filas]);
|
const datos = useMemo(() => filas.filter((f)=>String(f[0]).toUpperCase()!=="TOTAL GENERAL"), [filas]);
|
||||||
|
|||||||
Reference in New Issue
Block a user