import React, { ComponentProps, Dispatch, SetStateAction } from "react"; import _ from "lodash"; import { ChevronLeft, ChevronRight } from "lucide-react"; import { twMerge } from "tailwind-merge"; import Row from "../layout/Row"; import Button from "../layout/Button"; import EmptyContent from "./EmptyContent"; import Span from "../layout/Span"; type Props = ComponentProps & { page?: number; setPage?: Dispatch>; count?: number; limit?: number; }; /** * # Pagination Component * @param param0 * @returns */ export default function Pagination({ count, page, setPage, limit, ...props }: Props) { if (!count || !page || !limit) return ( ); const isLimit = limit * page >= count; const pages = Math.ceil(count / limit); return ( {pages > 1 && ( )} Page {page} / {pages} {pages > 1 && ( {Array(pages) .fill(0) .map((p, index) => { const isCurrent = page == index + 1; return ( ); })} )} {pages > 1 && ( )} ); }