diff --git a/frontend/src/pages/Ocupabilidad.jsx b/frontend/src/pages/Ocupabilidad.jsx index a31b8b3..1fbe444 100644 --- a/frontend/src/pages/Ocupabilidad.jsx +++ b/frontend/src/pages/Ocupabilidad.jsx @@ -4,6 +4,7 @@ import { api } from "../lib/api"; import { Loader, ErrorBox, ProgressBar, Filters, Select } from "../components/UI"; import { useColumnasAjustables } from "../lib/useColumnasAjustables"; import Modal from "../components/Modal"; +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]; @@ -28,11 +29,16 @@ export default function Ocupabilidad() { useEffect(() => { let activo = true; - setLoading(true); setError(null); - api.ocupabilidad(ano, mes, sede, programa) - .then((res) => { if (activo) { setDatos(res.datos || []); setLoading(false); } }) - .catch((e) => { if (activo) { setError(e.message); setLoading(false); } }); - return () => { activo = false; }; + setVistaActual(`ocupabilidad:${ano}|${mes}|${sede}|${programa}`); + const cargar = () => { + setLoading(true); setError(null); + api.ocupabilidad(ano, mes, sede, programa) + .then((res) => { if (activo) { setDatos(res.datos || []); setLoading(false); } }) + .catch((e) => { if (activo) { setError(e.message); setLoading(false); } }); + }; + cargar(); + const off = onRefrescar(cargar); + return () => { activo = false; off(); }; }, [ano, mes, sede, programa]); // Toggle "Mostrar Reprogramados": si está apagado, ocultar filas de inicio