paginacion datastage

This commit is contained in:
2025-08-22 23:56:55 -06:00
parent 6309bc1b96
commit 8bc1e88aad

View File

@@ -146,12 +146,11 @@ export default function Datastage() {
if (success) setShowSuccessModal(true);
}, [success]);
// Cargar lista
const load = async () => {
const load = async (page = currentPage, pageSize = itemsPerPage) => {
setLoading(true);
setError(null);
try {
const data = await fetchDatastages();
// Defensive: if data is not the expected object, fallback to empty
const data = await fetchDatastages(page, pageSize);
if (data && Array.isArray(data.results)) {
setDatastages(data);
} else if (Array.isArray(data)) {
@@ -165,7 +164,10 @@ export default function Datastage() {
}
setLoading(false);
};
useEffect(() => { load(); }, []);
useEffect(() => {
load(currentPage, itemsPerPage);
}, [currentPage, itemsPerPage]);
// Ver detalle
const handleSelect = async (id) => {