"use client" import { ChevronLeft, ChevronRight, MoreHorizontal } from "lucide-react" import * as React from "react" import { cn } from "../utils/cn" import { Button } from "./ui/button" interface PaginationProps { currentPage: number totalPages: number onPageChange: (page: number) => void className?: string } const Pagination = ({ currentPage, totalPages, onPageChange, className }: PaginationProps) => { // Generate page numbers to display const getPageNumbers = () => { const pages = [] const maxPagesToShow = 5 if (totalPages <= maxPagesToShow) { // Show all pages if there are fewer than maxPagesToShow for (let i = 1; i <= totalPages; i++) { pages.push(i) } } else { // Always show first page pages.push(1) // Calculate start and end of page range let start = Math.max(2, currentPage - 1) let end = Math.min(totalPages - 1, currentPage + 1) // Adjust if at the beginning or end if (currentPage <= 2) { end = Math.min(totalPages - 1, 4) } else if (currentPage >= totalPages - 1) { start = Math.max(2, totalPages - 3) } // Add ellipsis if needed if (start > 2) { pages.push(-1) // -1 represents ellipsis } // Add middle pages for (let i = start; i <= end; i++) { pages.push(i) } // Add ellipsis if needed if (end < totalPages - 1) { pages.push(-2) // -2 represents ellipsis } // Always show last page if (totalPages > 1) { pages.push(totalPages) } } return pages } const pageNumbers = getPageNumbers() return ( ) } const PaginationContent = React.forwardRef>( ({ className, ...props }, ref) => { return