import { Link } from 'react-router-dom'; import { Pagination, PaginationItem, PaginationLink } from 'reactstrap'; import { pageIsEllipsis, keyForPage, progressivePagination, prettifyPageNumber, NumberOrEllipsis, } from '../utils/helpers/pagination'; import { ShlinkPaginator } from '../api/types'; interface PaginatorProps { paginator?: ShlinkPaginator; serverId: string; currentQueryString?: string; } export const Paginator = ({ paginator, serverId, currentQueryString = '' }: PaginatorProps) => { const { currentPage = 0, pagesCount = 0 } = paginator ?? {}; const urlForPage = (pageNumber: NumberOrEllipsis) => `/server/${serverId}/list-short-urls/${pageNumber}${currentQueryString}`; if (pagesCount <= 1) { return null; } const renderPages = () => progressivePagination(currentPage, pagesCount).map((pageNumber, index) => ( {prettifyPageNumber(pageNumber)} )); return ( {renderPages()} = pagesCount}> ); };