type PaginationControlsProps = { total: number; limit: number; page: number; onPageChange: (next: number) => void; }; const numberFormatter = new Intl.NumberFormat("ru-RU"); export const PaginationControls = ({ total, limit, page, onPageChange }: PaginationControlsProps) => { const safeLimit = Math.max(limit, 1); const totalPages = Math.max(1, Math.ceil(Math.max(total, 0) / safeLimit)); const clampedPage = Math.min(Math.max(page, 0), totalPages - 1); const startIndex = total === 0 ? 0 : clampedPage * safeLimit + 1; const endIndex = total === 0 ? 0 : Math.min(total, (clampedPage + 1) * safeLimit); const canGoPrev = clampedPage > 0; const canGoNext = clampedPage + 1 < totalPages; return (
{total === 0 ? "Нет записей" : `Показаны ${numberFormatter.format(startIndex)}–${numberFormatter.format(endIndex)} из ${numberFormatter.format(total)}`}
Стр. {numberFormatter.format(clampedPage + 1)} из {numberFormatter.format(totalPages)}
); };