import * as React from 'react'
import { ChevronLeft, ChevronRight, MoreHorizontal } from 'lucide-react'
import { cn } from '@/lib/utils'
import { type ButtonProps, buttonVariants } from '@/components/ui/button'
const Pagination = ({ className, ...props }: React.ComponentProps<'nav'>) => (
)
Pagination.displayName = 'Pagination'
const PaginationContent = React.forwardRef<
HTMLUListElement,
React.ComponentProps<'ul'>
>(({ className, ...props }, ref) => (
))
PaginationContent.displayName = 'PaginationContent'
const PaginationItem = React.forwardRef<
HTMLLIElement,
React.ComponentProps<'li'>
>(({ className, ...props }, ref) => (
))
PaginationItem.displayName = 'PaginationItem'
type PaginationLinkProps = {
isActive?: boolean
isDisabled?: boolean
} & Pick &
React.ComponentProps<'a'>
const PaginationLink = ({
className,
isActive,
isDisabled,
size = 'icon',
...props
}: PaginationLinkProps) => (
)
PaginationLink.displayName = 'PaginationLink'
const PaginationPrevious = ({
className,
isDisabled,
...props
}: React.ComponentProps) => (
Previous
)
PaginationPrevious.displayName = 'PaginationPrevious'
const PaginationNext = ({
className,
isDisabled,
...props
}: React.ComponentProps) => (
Next
)
PaginationNext.displayName = 'PaginationNext'
const PaginationEllipsis = ({
className,
...props
}: React.ComponentProps<'span'>) => (
More pages
)
PaginationEllipsis.displayName = 'PaginationEllipsis'
interface PaginationProps {
currentPage: number
totalPages: number
baseUrl: string
}
const PaginationComponent: React.FC = ({
currentPage,
totalPages,
baseUrl,
}) => {
const pages = Array.from({ length: totalPages }, (_, i) => i + 1)
const getPageUrl = (page: number) => {
if (page === 1) return baseUrl
return `${baseUrl}${page}`
}
return (
1 ? getPageUrl(currentPage - 1) : undefined}
isDisabled={currentPage === 1}
/>
{pages.map((page) => (
{page}
))}
{totalPages > 5 && (
)}
)
}
export default PaginationComponent