diff --git a/packages-next/admin-ui/src/pages/ListPage/pagination.tsx b/packages-next/admin-ui/src/pages/ListPage/pagination.tsx deleted file mode 100644 index 05184af8e89..00000000000 --- a/packages-next/admin-ui/src/pages/ListPage/pagination.tsx +++ /dev/null @@ -1,130 +0,0 @@ -/** @jsx jsx */ -import { jsx, Center, Stack, useTheme } from '@keystone-ui/core'; - -import { Link, useRouter } from '../../router'; -import { useList } from '../..'; - -function Page({ page, currentPage }: { page: number; currentPage: number }) { - const { query } = useRouter(); - const newQuery = { ...query, page: page as number | undefined }; - if (page === 1) { - delete newQuery.page; - } - - return ( - - {page} - - ); -} - -export function Pagination({ - currentPage, - total, - pageSize, - listKey, -}: { - currentPage: number; - total: number; - pageSize: number; - listKey: string; -}) { - const list = useList(listKey); - - if (total <= pageSize) return null; - - const pages = []; - const totalPages = Math.ceil(total / pageSize); - - let minPage = 1; - let maxPage = totalPages; - const limit = 5; - if (limit < totalPages) { - const rightLimit = Math.floor(limit / 2); - const leftLimit = rightLimit + (limit % 2) - 1; - minPage = currentPage - leftLimit; - maxPage = currentPage + rightLimit; - - if (minPage < 1) { - maxPage = limit; - minPage = 1; - } - - if (maxPage > totalPages) { - minPage = totalPages - limit + 1; - maxPage = totalPages; - } - } - - if (minPage > 1) { - pages.push(); - } - - for (let page = minPage; page <= maxPage; page++) { - pages.push(); - } - - // go to last - if (maxPage < totalPages) { - pages.push(); - } - return ( -
- - {pages} - - -
- ); -} - -export function PaginationLabel({ - currentPage, - pageSize, - plural, - singular, - total, -}: { - currentPage: number; - pageSize: number; - plural: string; - singular: string; - total: number; -}) { - if (!total) { - return No {plural}; - } - - let count = ''; - const start = pageSize * (currentPage - 1) + 1; - const end = Math.min(start + pageSize - 1, total); - - if (total > pageSize) { - count = `${start} to ${end} of ${total} ${plural}`; - } else { - count = `${total} `; - if (total > 1 && plural) { - count += plural; - } else if (total === 1 && singular) { - count += singular; - } - } - - return ( - - Showing {count} - - ); -}