import { CaretLeftIcon, CaretRightIcon, DotsThreeIcon, } from '@phosphor-icons/react'; import { Button } from './ui/button'; import { ButtonGroup } from './ui/button-group'; type PaginationProps = { currentPage: number; totalPages: number; onPageChange: (page: number) => void; }; const Pagination = ({ currentPage, totalPages, onPageChange, }: PaginationProps) => { const getPageNumbers = () => { const pages: (number | string)[] = []; if (totalPages <= 5) { // Hiển thị tất cả nếu trang ít for (let i = 1; i <= totalPages; i++) { pages.push(i); } } else { if (currentPage <= 3) { pages.push(1, 2, 3, 'dot', totalPages); } else if (currentPage >= totalPages - 2) { pages.push(1, 'dot', totalPages - 2, totalPages - 1, totalPages); } else { pages.push(1, 'dot', currentPage, 'dot', totalPages); } } return pages; }; const pages = getPageNumbers(); return (