'use client' import { Button } from '@/components/ui/button' import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@/components/ui/select' import { ChevronLeft, ChevronRight } from 'lucide-react' import type { PaginationState } from '@/hooks/use-pagination' const PAGE_SIZE_OPTIONS = [10, 20, 50, 100] export function PaginationControls({ pagination, showPageSize = true, noun = 'items', }: { pagination: PaginationState showPageSize?: boolean noun?: string }) { const { page, totalPages, totalItems, canPrevious, canNext, previous, next, setPage, setPageSize, pageSize, startIndex, endIndex } = pagination if (totalItems === 0) return null // Build page numbers to show const pages: (number | 'ellipsis')[] = [] if (totalPages <= 7) { for (let i = 1; i <= totalPages; i++) pages.push(i) } else { pages.push(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 (
{startIndex}–{endIndex} of {totalItems} {noun}
{showPageSize && ( )} {pages.map((p, i) => p === 'ellipsis' ? ( ... ) : ( ) )}
) }