'use client'; import { Table } from '@tanstack/react-table'; import { ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight, } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@/components/ui/select'; const PAGE_SIZE_OPTIONS = [10, 20, 40, 50, 100]; export function TableFooter({ table, totalItems, pageSize, onPageSizeChange, }: { table: Table; totalItems: number; pageSize?: number; onPageSizeChange?: (pageSize: number) => void; }) { const currentPageSize = pageSize ?? table.getState().pagination.pageSize; const selectedRowCount = Object.keys(table.getState().rowSelection).length; const pageIndex = table.getState().pagination.pageIndex; const rawPageCount = table.getPageCount(); const pageCount = Math.max( 1, Number.isFinite(rawPageCount) && rawPageCount > 0 ? rawPageCount : 1, ); return (
{selectedRowCount} of {totalItems} row(s) selected.
{onPageSizeChange ? (
Rows per page
) : null}
Page {pageIndex + 1} of {pageCount}
); }