import React from 'react'; import clsx from 'clsx'; import { ChevronLeft, ChevronRight } from 'lucide-react'; import { useTranslation } from 'react-i18next'; export interface PaginationProps { currentPage: number; totalPages: number; total: number; pageSize: number; onPageChange: (page: number) => void; } export function Pagination({ currentPage, totalPages, total, pageSize, onPageChange }: PaginationProps) { const { t } = useTranslation(); const start = total === 0 ? 0 : (currentPage - 1) * pageSize + 1; const end = Math.min(currentPage * pageSize, total); const pages: number[] = []; const maxVisible = 5; const halfVisible = Math.floor(maxVisible / 2); let startPage = Math.max(1, currentPage - halfVisible); let endPage = Math.min(totalPages, startPage + maxVisible - 1); if (endPage - startPage < maxVisible - 1) { startPage = Math.max(1, endPage - maxVisible + 1); } for (let i = startPage; i <= endPage; i++) { pages.push(i); } if (totalPages <= 1) return null; return ( ); }