import React from 'react'; 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); } } return (

Showing  {Math.max(start, Math.min(pagination.total, 1))}  to  {end} of  {pagination.total} results.

{pagination.totalPages > 1 &&
onPageSelect(1)}> {pages.previous.reverse().map((value) => ( onPageSelect(value)}> {value} ))} {pages.next.map((value) => ( onPageSelect(value)}> {value} ))} onPageSelect(total)}>
}
); }; export default PaginationFooter;