import { ArrowBackRounded, ArrowForwardRounded, Remove, } from '@mui/icons-material' import clsx from 'clsx' import { useEffect } from 'react' import { Button } from './buttons' import { IconButton } from './icon_buttons' import { Loader } from './logo' export const PAGINATION_MIN_PAGE = 1 export type PaginationProps = { total: number page: number setPage: (page: number) => void pageSize: number className?: string /** * Show loading indicator over current page. */ loading?: boolean } export const Pagination = ({ total, page: _page, setPage, pageSize, className, loading, }: PaginationProps) => { const maxPage = Math.ceil(total / pageSize) const page = Math.min(Math.max(PAGINATION_MIN_PAGE, _page), maxPage) // If page is out of bounds, correct it. useEffect(() => { if (_page !== page) { setPage(maxPage) } }, [_page, maxPage, page, setPage]) if (maxPage <= PAGINATION_MIN_PAGE) { return null } return (