diff --git a/src/components/OrganizationTable.tsx b/src/components/OrganizationTable.tsx index d8c3d29..5dc726a 100644 --- a/src/components/OrganizationTable.tsx +++ b/src/components/OrganizationTable.tsx @@ -32,7 +32,6 @@ export default function OrganizationTable({ const router = useRouter(); const [page, setPage] = useState(0); - const [rowsPerPage, setRowsPerPage] = useState(5); const tableContainerRef = useRef(null); const handleCheckboxChange = (name: string) => { @@ -64,30 +63,12 @@ export default function OrganizationTable({ }, [sortedOrgs]); const paginatedRows = - organizationsWithHours.slice( - page * rowsPerPage, - page * rowsPerPage + rowsPerPage - ) || []; + organizationsWithHours.slice(page * 6, page * 6 + 6) || []; useEffect(() => { setPage(0); }, [organizations?.length]); - useEffect(() => { - const updateRowsPerPage = () => { - if (tableContainerRef.current) { - const containerHeight = tableContainerRef.current.clientHeight; - const rowHeight = 74.5; - const calculatedRows = Math.floor(containerHeight / rowHeight); - setRowsPerPage(calculatedRows > 0 ? calculatedRows : 1); - } else { - setRowsPerPage(3); - } - }; - - updateRowsPerPage(); - }, []); - return ( - Page {page + 1} of{" "} - {Math.ceil((organizations.length || 0) / rowsPerPage)} + Page {page + 1} of {Math.ceil((organizations.length || 0) / 6)} @@ -384,20 +364,17 @@ export default function OrganizationTable({ setPage((prev) => Math.min( prev + 1, - Math.ceil((organizations.length || 0) / rowsPerPage) - 1 + Math.ceil((organizations.length || 0) / 6) - 1 ) ) } - disabled={ - page >= Math.ceil((organizations.length || 0) / rowsPerPage) - 1 - } + disabled={page >= Math.ceil((organizations.length || 0) / 6) - 1} sx={{ textTransform: "none", fontSize: "14px", fontWeight: 600, color: - page >= - Math.ceil((organizations.length || 0) / rowsPerPage) - 1 + page >= Math.ceil((organizations.length || 0) / 6) - 1 ? "#D0D5DD" : "#145A5A", borderRadius: 2, diff --git a/src/components/VolunteerTable.tsx b/src/components/VolunteerTable.tsx index 15cefdc..77a1628 100644 --- a/src/components/VolunteerTable.tsx +++ b/src/components/VolunteerTable.tsx @@ -38,7 +38,6 @@ export default function VolunteerTable({ const router = useRouter(); const [page, setPage] = useState(0); - const [rowsPerPage, setRowsPerPage] = useState(5); const tableContainerRef = useRef(null); const handleCheckboxChange = (name: string) => { @@ -69,31 +68,12 @@ export default function VolunteerTable({ })); }, [sortedUsers]); - const paginatedRows = - usersWithHours?.slice( - page * rowsPerPage, - page * rowsPerPage + rowsPerPage - ) || []; + const paginatedRows = usersWithHours?.slice(page * 6, page * 6 + 6) || []; useEffect(() => { setPage(0); }, [users?.length]); - useEffect(() => { - const updateRowsPerPage = () => { - if (tableContainerRef.current && fromVolunteerPage) { - const containerHeight = tableContainerRef.current.clientHeight; - const rowHeight = 74.5; - const calculatedRows = Math.floor(containerHeight / rowHeight); - setRowsPerPage(calculatedRows > 0 ? calculatedRows : 1); - } else { - setRowsPerPage(3); - } - }; - - updateRowsPerPage(); - }, [fromVolunteerPage]); - return ( - Page {page + 1} of {Math.ceil((users?.length || 0) / rowsPerPage)} + Page {page + 1} of {Math.ceil((users?.length || 0) / 6)} @@ -425,21 +405,16 @@ export default function VolunteerTable({