import Icon from "./../Icon" import { faChevronLeft } from "@fortawesome/free-solid-svg-icons"; export interface Pagination { current: number, count: number, onChange: (...args: any[]) => any, } export interface Props extends Pagination { className?: string } const Paginate = ({ current, count, onChange, className }: Props): JSX.Element => { const getPages = () => { if (count === 2) return [1, 2] if (count > 2) { if (current === 1) return [1, 2, 3] if (current === count) return [count - 2, count - 1, count] return [current - 1, current, current + 1] } return [] } return ( <> { count > 1 &&
{ count > 3 && current > 2 && } { current > 1 && } { getPages().map((page, index) => ( )) } { current < count && } { count > 3 && current < count - 1 && }
} ) } export default Paginate