import type { 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 (!page || !limit) return ; if (!count) return null; const isLimit = limit * page >= count; const pages = Math.ceil(count / limit); const next_button = ( ); return ( {pages > 1 && ( )} {pages > 1 &&
{next_button}
} Page {page} / {pages} {pages > 1 && ( {Array(pages) .fill(0) .map((p, index) => { const isCurrent = page == index + 1; return ( ); })} )} {pages > 1 &&
{next_button}
}
); }