import { motion } from 'framer-motion' interface PaginationProps { currentPage: number lastPage: number total: number onPageChange: (page: number) => void itemsPerPage: number onItemsPerPageChange: (items: number) => void } export default function Pagination({ currentPage, lastPage, total, onPageChange, itemsPerPage, onItemsPerPageChange }: PaginationProps) { const handlePrevious = () => { if (currentPage > 1) { onPageChange(currentPage - 1) } } const handleNext = () => { if (currentPage < lastPage) { onPageChange(currentPage + 1) } } const handlePageSelect = (page: number) => { onPageChange(page) } // Generate page numbers to show const getVisiblePages = () => { const pages: number[] = [] const maxVisible = 5 if (lastPage <= maxVisible) { for (let i = 1; i <= lastPage; i++) { pages.push(i) } } else { const start = Math.max(1, currentPage - 2) const end = Math.min(lastPage, start + maxVisible - 1) for (let i = start; i <= end; i++) { pages.push(i) } } return pages } if (lastPage <= 1) { return null } return (
{/* Items per page selector */}
Show: of {total} items
{/* Pagination controls */}
Previous
{getVisiblePages().map((page) => ( handlePageSelect(page)} className={`w-8 h-8 text-sm rounded-lg transition-colors ${ currentPage === page ? 'bg-purple-600 text-white' : 'bg-white dark:bg-gray-700 text-gray-900 dark:text-white hover:bg-gray-100 dark:hover:bg-gray-600' }`} whileHover={{ scale: 1.1 }} whileTap={{ scale: 0.9 }} > {page} ))}
Next
{/* Page info */}
Page {currentPage} of {lastPage}
) }