import { PaginationDataSet } from '@/api/http'; import classNames from 'classnames'; import { Button } from '@/components/elements/button/index'; import { ChevronDoubleLeftIcon, ChevronDoubleRightIcon } from '@heroicons/react/solid'; interface Props { className?: string; pagination: PaginationDataSet; onPageSelect: (page: number) => void; } const PaginationFooter = ({ pagination, className, onPageSelect }: Props) => { const start = (pagination.currentPage - 1) * pagination.perPage; const end = (pagination.currentPage - 1) * pagination.perPage + pagination.count; const { currentPage: current, totalPages: total } = pagination; const pages = { previous: [] as number[], next: [] as number[] }; for (let i = 1; i <= 2; i++) { if (current - i >= 1) { pages.previous.push(current - i); } if (current + i <= total) { pages.next.push(current + i); } } if (pagination.total === 0) { return null; } const buttonProps = (page: number) => ({ size: Button.Sizes.Small, shape: Button.Shapes.IconSquare, variant: Button.Variants.Secondary, onClick: () => onPageSelect(page), }); return (
Showing {Math.max(start, Math.min(pagination.total, 1))} to {end} of {pagination.total} results.
{pagination.totalPages > 1 && (