import styles from "./PaginationControls.module.css";
interface PaginationControlsProps {
    totalPages: number | null;
    setCurrentPage: (page: number) => void;
    currentPage: number | null;
}
export default function PaginationControls( {totalPages, setCurrentPage, currentPage}: PaginationControlsProps) {
    {/* Pagination Controls */}
    if (!totalPages || totalPages <= 1) return <></>
    return <> {totalPages  > 1 && (
        <div className={styles.paginationControls}>
            <button
                onClick={() => setCurrentPage(Math.max(1, currentPage ? currentPage  - 1: 0))}
                disabled={currentPage === 1}>
                Previous
            </button>

            <span>
            Page {currentPage} of {totalPages}
            </span>

            <button
                onClick={() => setCurrentPage(Math.min(totalPages, currentPage ? currentPage + 1 : 1))}
                disabled={currentPage === totalPages}>
                Next
            </button>
        </div>
    )}
    </>
}