// * Packages import { Link } from "@inertiajs/react"; // * Components shadcn import { Button } from "@/components/ui/button"; import { Pagination, PaginationContent, PaginationItem, } from "@/components/ui/pagination"; // * Other import { PaginatorLink } from "@/back/types/global"; type PaginationCustomProps = { links: Array; }; export default function PaginationCustom({ links }: PaginationCustomProps) { const page = Number(new URLSearchParams(window.location.search).get("page")) || 1; const lastPage = links.length - 1; if (links.length > 3) { return ( {links.map((link, index) => { if ( index === 0 || index === lastPage || index === page || index === page - 1 || index === page + 1 || index === 1 || index === lastPage - 1 ) { const condition = (index === 0 && page === 1) || (index === lastPage && page === lastPage - 1) || index === page; return ( ); } if ( (index === 2 && page > 3) || (index === lastPage - 2 && page < lastPage - 2) ) { return ( ... ); } return null; })} ); } return null; }