"use client";
interface PaginationProps {
page: number;
totalPages: number;
onPageChange: (page: number) => void;
}
export default function Pagination({ page, totalPages, onPageChange }: PaginationProps) {
if (totalPages <= 1) return null;
const pages: number[] = [];
const maxShow = 7;
let start = Math.max(1, page - Math.floor(maxShow / 2));
const end = Math.min(totalPages, start + maxShow - 1);
start = Math.max(1, end - maxShow + 1);
for (let i = start; i <= end; i++) pages.push(i);
const btn = "px-2.5 py-1.5 text-[12px] rounded-md border border-line hover:bg-surface transition-colors";
return (
{start > 1 && (
<>
{start > 2 && ...}
>
)}
{pages.map((p) => (
))}
{end < totalPages && (
<>
{end < totalPages - 1 && ...}
>
)}
);
}