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