import { Box } from '@mantine/core';
import dayjs from 'dayjs';
import { DataTable } from 'mantine-datatable';
import { useEffect, useState } from 'react';
import employees from '~/data/employees.json';
const PAGE_SIZES = [10, 15, 20];
export default function PaginationExampleWithPageSizeSelector() {
const [pageSize, setPageSize] = useState(PAGE_SIZES[1]);
const [page, setPage] = useState(1);
const [records, setRecords] = useState(employees.slice(0, pageSize));
const from = (page - 1) * pageSize;
const to = from + pageSize;
setRecords(employees.slice(from, to));
<Box sx={{ height: 300 }}>
{ accessor: 'firstName', width: 100 },
{ accessor: 'lastName', width: 100 },
{ accessor: 'email', width: '100%' },
render: ({ birthDate }) => dayjs(birthDate).format('MMM D YYYY'),
totalRecords={employees.length}
recordsPerPage={pageSize}
onPageChange={(p) => setPage(p)}
recordsPerPageOptions={PAGE_SIZES}
onRecordsPerPageChange={setPageSize}