interface PaginationProps {
page: number;
previousPage?: number;
nextPage?: number;
total?: number;
limit?: number;
onPageChange: (page: number) => void;
}
export function Pagination({
page,
previousPage,
nextPage,
total,
limit,
onPageChange,
}: PaginationProps) {
if (!previousPage && !nextPage) {
return null;
}
const totalPages = total && limit ? Math.ceil(total / limit) : undefined;
return (
{previousPage && previousPage > 0 ? (
) : null}
{totalPages ? (
Page {page} of {totalPages}
) : null}
{nextPage && nextPage > 0 ? (
) : null}
);
}