import { Table } from "@tanstack/react-table" import clsx from "clsx" import { useMemo } from "react" import Button from "../../fundamentals/button" import ArrowLeftIcon from "../../fundamentals/icons/arrow-left-icon" import ArrowRightIcon from "../../fundamentals/icons/arrow-right-icon" type Props = { count?: number table: Table className?: string } /** * Table pagnination component that is compatible with @tanstack/react-table */ export const TablePagination = ({ count = 0, table, className, }: Props) => { const { getState, getPageCount, getCanNextPage, getCanPreviousPage, previousPage, nextPage, } = table const { pageIndex, pageSize } = getState().pagination const { from, to } = useMemo(() => { const from = pageIndex * pageSize + 1 const to = Math.min(count, (pageIndex + 1) * pageSize) return { from, to } }, [count, pageIndex, pageSize]) return (

{`${from} – ${to} of ${count} results`}

{`${getState().pagination.pageIndex + 1} of ${getPageCount()}`}

) }