import React from 'react'; import type { RowData, Table as TanStackTable } from '@tanstack/react-table'; import { ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight } from 'lucide-react'; import Button from '@/components/elements/Button'; import { cn } from '@/lib/cn'; interface Props { table: TanStackTable; total: number; count: number; itemLabel?: string; className?: string; } const PageButton = ({ label, children, ...props }: React.ComponentProps & { label: string }) => ( {children} ); export default function DataTablePagination({ table, total, count, itemLabel = 'items', className, }: Props) { const { pageIndex, pageSize } = table.getState().pagination; const pageCount = table.getPageCount(); const start = total === 0 ? 0 : pageIndex * pageSize + 1; const end = total === 0 ? 0 : Math.min(total, start + count - 1); const showPager = pageCount > 1 || pageIndex > 0; if (total === 0) { return null; } return (

Showing {start}– {end} of{' '} {total} {itemLabel}

{showPager ? (
table.setPageIndex(0)} > table.previousPage()} > Page {pageIndex + 1} of{' '} {Math.max(pageCount, 1)} table.nextPage()}> table.setPageIndex(Math.max(pageCount - 1, 0))} >
) : null}
); }