"use client"; /** * @common/components DataTable 내부 Pagination과 동일 마크업/클래스 (복제). * 공용 패키지 수정 없이 LogHistory 전용으로 둠. */ import { ChevronLeftIcon, ChevronRightIcon, DoubleArrowLeftIcon, DoubleArrowRightIcon, } from "@radix-ui/react-icons"; import { Button, cn } from "@common/components"; export type LogHistoryTablePaginationProps = { /** 총 페이지 수 (TanStack table.getPageCount()와 동일) */ pageCount: number; /** 0부터 시작하는 현재 페이지 인덱스 */ pageIndex: number; onPageIndexChange: (pageIndex: number) => void; }; export function LogHistoryTablePagination({ pageCount, pageIndex: currentPage, onPageIndexChange, }: LogHistoryTablePaginationProps) { const maxVisiblePages = 10; let startPage = Math.max(0, currentPage - maxVisiblePages / 2); const endPage = Math.min(pageCount, startPage + maxVisiblePages); if (endPage - startPage < maxVisiblePages) { startPage = Math.max(0, endPage - maxVisiblePages); } const pageNumbers = Array(endPage - startPage) .fill(0) .map((_, i) => startPage + i); const canPrevious = currentPage > 0; const canNext = pageCount > 0 && currentPage < pageCount - 1; return (