import React from 'react'; function Pagination({ numOfItems, itemsPerPage = 10, currentPage, onPageChange }) { const totalPages = Math.ceil(numOfItems / itemsPerPage); const pages = Array.from({ length: totalPages }, (_, index) => index + 1); const maxPageButtons = 5; // Maximum number of page buttons to display const handlePrevious = () => { if (currentPage > 1) onPageChange(currentPage - 1); }; const handleNext = () => { if (currentPage < totalPages) onPageChange(currentPage + 1); }; const getPageButtons = () => { if (totalPages <= maxPageButtons) { return pages; } const half = Math.floor(maxPageButtons / 2); let start = Math.max(1, currentPage - half); let end = Math.min(totalPages, currentPage + half); if (currentPage <= half) { end = maxPageButtons; } else if (currentPage + half >= totalPages) { start = totalPages - maxPageButtons + 1; } return Array.from({ length: end - start + 1 }, (_, index) => start + index); }; return (

Showing {(currentPage - 1) * itemsPerPage + 1} to {Math.min(currentPage * itemsPerPage, numOfItems)} of {numOfItems} applications

); } export default Pagination;