import { Pagination as BPagination } from 'react-bootstrap'; import { v4 as uuidv4 } from 'uuid'; function Pagination({ pageIndex, pageCount, incrementPage, canNextPage, decrementPage, canPrevPage, onClick }) { const totalPage = Array.from({ length: pageCount }, (_, i) => i); const displayedCount = pageIndex + 1 < 5 || pageIndex + 5 > pageCount ? 5 : 3; let start; if (pageIndex + 1 < 5) { start = Math.max(pageIndex - displayedCount, 0); } else if (pageIndex + 5 > pageCount) { start = pageCount - displayedCount; } else { start = pageIndex - 1; } return ( {pageIndex + 1 >= 5 ? ( <> onClick(0)}>1 ) : null} {totalPage.slice(start, start + displayedCount).map((page) => ( onClick(page)}> {page + 1} ))} {pageIndex + 5 <= pageCount ? ( <> onClick(pageCount - 1)}>{pageCount} ) : null} ); } export default Pagination;