import React, { useState } from 'react'; import SingleArrowLeft from '../assets/single-left-arrow.svg'; import SingleArrowRight from '../assets/single-right-arrow.svg'; import DoubleArrowLeft from '../assets/double-arrow-left.svg'; import DoubleArrowRight from '../assets/double-arrow-right.svg'; interface PaginationProps { currentPage: number; totalPages: number; rowsPerPage: number; onPageChange: (page: number) => void; onRowsPerPageChange: (rows: number) => void; } const Pagination: React.FC = ({ currentPage, totalPages, rowsPerPage, onPageChange, onRowsPerPageChange, }) => { const [isDropdownOpen, setIsDropdownOpen] = useState(false); const rowsPerPageOptions = [5, 10, 20, 50]; const toggleDropdown = () => setIsDropdownOpen((prev) => !prev); const handlePreviousPage = () => { if (currentPage > 1) { onPageChange(currentPage - 1); } }; const handleNextPage = () => { if (currentPage < totalPages) { onPageChange(currentPage + 1); } }; const handleFirstPage = () => { onPageChange(1); }; const handleLastPage = () => { onPageChange(totalPages); }; const handleSelectRowsPerPage = (rows: number) => { setIsDropdownOpen(false); onRowsPerPageChange(rows); }; return (
{/* Rows per page dropdown */}
Rows per page:
{rowsPerPageOptions.map((option) => (
handleSelectRowsPerPage(option)} className={`cursor-pointer px-4 py-2 text-xs hover:bg-gray-100 dark:hover:bg-neutral-700 ${ rowsPerPage === option ? 'bg-gray-100 dark:bg-neutral-700 dark:text-light-gray' : 'bg-white dark:bg-dark-charcoal dark:text-light-gray' }`} > {option}
))}
{/* Pagination controls */}
Page {currentPage} of {totalPages}
); }; export default Pagination;