import { ChevronLeft, ChevronRight } from 'lucide-react' import { cn } from '@/lib/utils' interface PaginationProps { page: number totalPages: number total: number pageSize: number onPageChange: (page: number) => void } export function Pagination({ page, totalPages, total, pageSize, onPageChange }: PaginationProps) { const start = (page - 1) * pageSize + 1 const end = Math.min(page * pageSize, total) const getPageNumbers = (): (number | 'ellipsis')[] => { if (totalPages <= 7) { return Array.from({ length: totalPages }, (_, i) => i + 1) } const pages: (number | 'ellipsis')[] = [1] if (page > 3) pages.push('ellipsis') for (let i = Math.max(2, page - 1); i <= Math.min(totalPages - 1, page + 1); i++) { pages.push(i) } if (page < totalPages - 2) pages.push('ellipsis') pages.push(totalPages) return pages } if (totalPages <= 1) return null const btnBase = cn( 'inline-flex h-8 min-w-8 items-center justify-center rounded-md text-sm font-medium', 'transition-colors disabled:opacity-50 disabled:pointer-events-none' ) return (
Showing {start}-{end} of {total}
{getPageNumbers().map((p, i) => p === 'ellipsis' ? ( ... ) : ( ) )}
) } export default Pagination