mirror of
https://github.com/strapi/strapi.git
synced 2025-09-27 01:09:49 +00:00
go to the last page if page doesn't exist
This commit is contained in:
parent
a92367510f
commit
8dbc3c09ee
@ -166,6 +166,22 @@ function ListView({
|
|||||||
data: { results, pagination: paginationResult },
|
data: { results, pagination: paginationResult },
|
||||||
} = await fetchClient.get(endPoint, options);
|
} = await fetchClient.get(endPoint, options);
|
||||||
|
|
||||||
|
// If user enters a page number that doesn't exist, redirect him to the last page
|
||||||
|
if (paginationResult.page > paginationResult.pageCount && paginationResult.pageCount > 0) {
|
||||||
|
const query = {
|
||||||
|
...params,
|
||||||
|
page: paginationResult.pageCount,
|
||||||
|
};
|
||||||
|
|
||||||
|
push({
|
||||||
|
pathname,
|
||||||
|
state: { from: pathname },
|
||||||
|
search: stringify(query),
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
notifyStatus(
|
notifyStatus(
|
||||||
formatMessage(
|
formatMessage(
|
||||||
{
|
{
|
||||||
@ -205,7 +221,17 @@ function ListView({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[formatMessage, getData, getDataSucceeded, notifyStatus, push, toggleNotification, fetchClient]
|
[
|
||||||
|
formatMessage,
|
||||||
|
getData,
|
||||||
|
getDataSucceeded,
|
||||||
|
notifyStatus,
|
||||||
|
push,
|
||||||
|
toggleNotification,
|
||||||
|
fetchClient,
|
||||||
|
params,
|
||||||
|
pathname,
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleConfirmDeleteAllData = React.useCallback(
|
const handleConfirmDeleteAllData = React.useCallback(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user