diff --git a/frontend/src/components/DocumentPagination.tsx b/frontend/src/components/DocumentPagination.tsx index 4000f83d..af849ed4 100644 --- a/frontend/src/components/DocumentPagination.tsx +++ b/frontend/src/components/DocumentPagination.tsx @@ -19,7 +19,10 @@ const Pagination: React.FC = ({ onPageChange, onRowsPerPageChange, }) => { - const [rowsPerPageOptions] = useState([5, 10, 15, 20]); + const [isDropdownOpen, setIsDropdownOpen] = useState(false); + const rowsPerPageOptions = [5, 10, 20, 50]; + + const toggleDropdown = () => setIsDropdownOpen((prev) => !prev); const handlePreviousPage = () => { if (currentPage > 1) { @@ -41,31 +44,51 @@ const Pagination: React.FC = ({ 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}
-
@@ -85,7 +108,7 @@ const Pagination: React.FC = ({ > arrow @@ -96,7 +119,7 @@ const Pagination: React.FC = ({ > arrow @@ -107,7 +130,7 @@ const Pagination: React.FC = ({ > arrow diff --git a/frontend/src/components/DropdownMenu.tsx b/frontend/src/components/DropdownMenu.tsx index 787d3b84..2e6c922c 100644 --- a/frontend/src/components/DropdownMenu.tsx +++ b/frontend/src/components/DropdownMenu.tsx @@ -48,7 +48,7 @@ export default function DropdownMenu({
+ {/* outside scrollable area */} + { + setCurrentPage(page); + refreshDocs(undefined, page, rowsPerPage); + }} + onRowsPerPageChange={(rows) => { + setRowsPerPage(rows); + setCurrentPage(1); + refreshDocs(undefined, 1, rows); + }} + /> + {/* Conditionally render the Upload modal based on modalState */} {modalState === 'ACTIVE' && (