import { HiOutlineChevronLeft, HiOutlineChevronRight } from 'react-icons/hi'
const PageLink = ({ active, label, page, onPageChange }) => {
const className = active ? 'z-10 px-3 py-2 leading-tight text-blue-600 border border-blue-300 bg-blue-50 hover:bg-blue-100 hover:text-blue-700 dark:border-gray-700 dark:bg-gray-700 dark:text-white' : 'px-3 py-2 leading-tight text-gray-500 bg-white border border-gray-300 hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white'
if (label === '« Previous') {
return (
onPageChange(+page - 1)}
className="block py-2 px-1 ml-0 leading-tight text-gray-500 bg-white border border-gray-300 rounded-l-lg hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white"
aria-label="Previous"
>
)
}
if (label == 'Next »') {
return (
onPageChange(+page + 1)}
className="block py-2 px-1 leading-tight text-gray-500 bg-white border border-gray-300 rounded-r-lg hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">
)
}
return (
onPageChange(label)}>
{ label }
)
}
// Previous, if on first page
// Next, if on last page
// and dots, if exists (...)
const PageInactive = ({ label }) => {
if (label === '« Previous') {
return (
)
}
if (label == 'Next »') {
return (
)
}
return (
{label}
)
}
export default ({ links, page, onPageChange }) => {
// dont render, if there's only 1 page (previous, 1, next)
if (links.links.length === 3) return null
return (
Showing {links.from}-{links.to} of {links.total}
{links.links.map(({ active, label, url }, index) => {
return url === null ? (
) : (
)
})}
)
}