'use client'
import { PAGE_SIZE } from '../_types'
interface PaginationProps {
currentPage: number
totalRecords: number
onPageChange: (page: number) => void
}
export function Pagination({ currentPage, totalRecords, onPageChange }: PaginationProps) {
const totalPages = Math.ceil(totalRecords / PAGE_SIZE)
return (
Zeige {totalRecords === 0 ? 0 : (currentPage - 1) * PAGE_SIZE + 1}–
{Math.min(currentPage * PAGE_SIZE, totalRecords)} von {totalRecords} Einträgen
{Array.from({ length: Math.min(totalPages, 5) }, (_, i) => {
const page = Math.max(1, Math.min(currentPage - 2, totalPages - 4)) + i
if (page < 1 || page > totalPages) return null
return (
)
})}
)
}