import { ChevronLeft, ChevronRight } from 'lucide-react'; import { useTranslation } from 'react-i18next'; import styles from './Pagination.module.css'; export interface PaginationProps { /** 1-indexed current page */ page: number; pageSize: number; total: number; onPageChange: (page: number) => void; onPageSizeChange?: (size: number) => void; pageSizeOptions?: number[]; } function buildPages(current: number, last: number): (number | '…')[] { if (last <= 7) return Array.from({ length: last }, (_, i) => i + 1); const pages: (number | '…')[] = [1]; if (current > 3) pages.push('…'); const start = Math.max(2, current - 1); const end = Math.min(last - 1, current + 1); for (let i = start; i <= end; i++) pages.push(i); if (current < last - 2) pages.push('…'); pages.push(last); return pages; } export function Pagination({ page, pageSize, total, onPageChange, onPageSizeChange, pageSizeOptions = [10, 25, 50], }: PaginationProps) { const { t } = useTranslation(); const lastPage = Math.max(1, Math.ceil(total / pageSize)); const from = Math.min(total, (page - 1) * pageSize + 1); const to = Math.min(total, page * pageSize); return (