'use client' import React from 'react' interface PaginationProps { currentPage: number totalPages: number hasNext: boolean hasPrevious: boolean isLoading: boolean onPageChange: (page: number) => void } export default function Pagination({ currentPage, totalPages, isLoading, onPageChange, }: PaginationProps) { if (totalPages <= 1) return null const renderPageNumbers = () => { const pages = [] const maxVisiblePages = 5 // максимальное количество видимых страниц // создаем кнопки страницы const createPageButton = (pageNum: number) => ( ) // всегда показываем первую страницу pages.push(createPageButton(1)) if (totalPages <= maxVisiblePages) { // если страниц мало, показываем все for (let i = 2; i <= totalPages; i++) { pages.push(createPageButton(i)) } } else { // если страниц много, показываем с многоточием if (currentPage > 3) { pages.push( ... ) } // показываем страницы вокруг текущей for ( let i = Math.max(2, currentPage - 1); i <= Math.min(totalPages - 1, currentPage + 1); i++ ) { pages.push(createPageButton(i)) } if (currentPage < totalPages - 2) { pages.push( ... ) } // всегда показываем последнюю страницу if (totalPages > 1) { pages.push(createPageButton(totalPages)) } } return pages } return (