import React from 'react'; import { clsx } from 'clsx'; import { ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight } from 'lucide-react'; import { useTranslation } from '@/hooks/useI18n'; import Button from './Button'; export interface PaginationProps { currentPage: number; totalPages: number; onPageChange: (page: number) => void; pageSize?: number; totalItems?: number; showPageNumbers?: boolean; showFirstLast?: boolean; className?: string; } /** * Pagination component */ export const Pagination = ({ currentPage, totalPages, onPageChange, pageSize, totalItems, showPageNumbers = true, showFirstLast = true, className, }: PaginationProps) => { const { t } = useTranslation(); const getPageNumbers = () => { 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 { rangeWithDots.push(totalPages); } return rangeWithDots; }; const pageNumbers = getPageNumbers(); if (totalPages <= 1) return null; return (