import { Link } from "@inertiajs/react"; import type { PaginatorLink } from "@/back/types/global"; import { Button } from "@/components/ui/button"; import { Pagination, PaginationContent, PaginationItem, } from "@/components/ui/pagination"; interface PaginationCustomProps { links: PaginatorLink[]; } export default function PaginationCustom({ links }: PaginationCustomProps) { const page = Number( new URLSearchParams(new URL(window.location.href).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; }