diff --git a/client/app/components/Pagination/index.jsx b/client/app/components/Pagination/index.jsx index 8381693b..5cdd2401 100644 --- a/client/app/components/Pagination/index.jsx +++ b/client/app/components/Pagination/index.jsx @@ -1,25 +1,57 @@ +'use client'; + import { motion } from 'framer-motion'; -import Tooltip from '@/app/components/Tooltip'; import { CgChevronLeft, CgChevronRight } from 'react-icons/cg'; +import { useEffect, useRef, useState } from 'react'; +import cn from '@/lib/cn'; -export default function Pagination({ page, next, previous, maxReached, loading }) { - return !loading ? ( - - - - +export default function Pagination({ page, setPage, loading, total, limit }) { + + const totalPages = Math.ceil(total / limit); + const pagesToShow = 2; + const start = Math.max(1, page - pagesToShow); + const end = Math.min(totalPages, page + pagesToShow); + const pages = Array.from({ length: end - start + 1 }, (_, i) => start + i); - - Page {page} - + return ( + + - - - + ))} + + - ) : null; + ) }