import React from 'react'; import { Button } from '@/components/ui/button'; import { CustomDropdown } from './CustomDropdown'; import { ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight } from 'lucide-react'; interface PaginationProps { currentPage: number; totalPages: number; totalItems: number; itemsPerPage: number; onPageChange: (page: number) => void; onItemsPerPageChange: (itemsPerPage: number) => void; className?: string; } const ITEMS_PER_PAGE_OPTIONS = [10, 25, 50, 100]; const Pagination: React.FC = ({ currentPage, totalPages, totalItems, itemsPerPage, onPageChange, onItemsPerPageChange, className = '' }) => { const startItem = (currentPage - 1) * itemsPerPage + 1; const endItem = Math.min(currentPage * itemsPerPage, totalItems); const handlePageChange = (page: number) => { if (page >= 1 && page <= totalPages) { onPageChange(page); } }; // Generate page numbers to show const getPageNumbers = () => { const pages: (number | string)[] = []; const maxVisiblePages = 5; if (totalPages <= maxVisiblePages) { // Show all pages if total is small for (let i = 1; i <= totalPages; i++) { pages.push(i); } } else { // Show first page pages.push(1); if (currentPage > 3) { pages.push('...'); } // Show pages around current page const start = Math.max(2, currentPage - 1); const end = Math.min(totalPages - 1, currentPage + 1); for (let i = start; i <= end; i++) { pages.push(i); } if (currentPage < totalPages - 2) { pages.push('...'); } // Show last page if (totalPages > 1) { pages.push(totalPages); } } return pages; }; if (totalItems === 0) { return null; } return ( ); }; export default Pagination;