Actualizar frontend/src/pages/Ocupabilidad.jsx
This commit is contained in:
@@ -4,6 +4,7 @@ import { api } from "../lib/api";
|
|||||||
import { Loader, ErrorBox, ProgressBar, Filters, Select } from "../components/UI";
|
import { Loader, ErrorBox, ProgressBar, Filters, Select } from "../components/UI";
|
||||||
import { useColumnasAjustables } from "../lib/useColumnasAjustables";
|
import { useColumnasAjustables } from "../lib/useColumnasAjustables";
|
||||||
import Modal from "../components/Modal";
|
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 MESES = ["ENERO","FEBRERO","MARZO","ABRIL","MAYO","JUNIO","JULIO","AGOSTO","SEPTIEMBRE","OCTUBRE","NOVIEMBRE","DICIEMBRE"];
|
||||||
const ANOS = [2024, 2025, 2026];
|
const ANOS = [2024, 2025, 2026];
|
||||||
@@ -28,11 +29,16 @@ export default function Ocupabilidad() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let activo = true;
|
let activo = true;
|
||||||
|
setVistaActual(`ocupabilidad:${ano}|${mes}|${sede}|${programa}`);
|
||||||
|
const cargar = () => {
|
||||||
setLoading(true); setError(null);
|
setLoading(true); setError(null);
|
||||||
api.ocupabilidad(ano, mes, sede, programa)
|
api.ocupabilidad(ano, mes, sede, programa)
|
||||||
.then((res) => { if (activo) { setDatos(res.datos || []); setLoading(false); } })
|
.then((res) => { if (activo) { setDatos(res.datos || []); 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, sede, programa]);
|
}, [ano, mes, sede, programa]);
|
||||||
|
|
||||||
// Toggle "Mostrar Reprogramados": si está apagado, ocultar filas de inicio
|
// Toggle "Mostrar Reprogramados": si está apagado, ocultar filas de inicio
|
||||||
|
|||||||
Reference in New Issue
Block a user