import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, } from '@/components/ui/pagination' import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@/components/ui/select' interface AppPaginationProps { currentPage: number totalPages: number totalCount: number pageSize: number pageSizeOptions?: number[] onPageChange: (page: number) => void onPageSizeChange: (size: number) => void itemName?: string // e.g., "items", "extractions", "playlists" } export function AppPagination({ currentPage, totalPages, totalCount, pageSize, pageSizeOptions = [10, 20, 50, 100], onPageChange, onPageSizeChange, itemName = 'items', }: AppPaginationProps) { // Don't render if there are no items if (totalCount === 0) return null const getVisiblePages = () => { const delta = 2 const range = [] const rangeWithDots = [] for ( let i = Math.max(2, currentPage - delta); i <= Math.min(totalPages - 1, currentPage + delta); i++ ) { range.push(i) } if (currentPage - delta > 2) { rangeWithDots.push(1, '...') } else { rangeWithDots.push(1) } rangeWithDots.push(...range) if (currentPage + delta < totalPages - 1) { rangeWithDots.push('...', totalPages) } else if (totalPages > 1) { rangeWithDots.push(totalPages) } return rangeWithDots } const startItem = Math.min((currentPage - 1) * pageSize + 1, totalCount) const endItem = Math.min(currentPage * pageSize, totalCount) return (
Showing {startItem} to {endItem} of {totalCount} {itemName}