diff --git a/src/components/projects/ProjectsList.tsx b/src/components/projects/ProjectsList.tsx index 9044014..cba7b88 100644 --- a/src/components/projects/ProjectsList.tsx +++ b/src/components/projects/ProjectsList.tsx @@ -9,7 +9,6 @@ import TablePagination from '@mui/material/TablePagination'; import TableRow from '@mui/material/TableRow'; import { Button } from '@mui/material'; import { Link } from 'react-router-dom'; -import { useState } from 'react'; const columns = [ { @@ -33,7 +32,7 @@ const columns = [ { id: 'term', label: 'Term', - Cell: (row: any) => ( + Cell: (row:any) => ( (row.perpetuity !== '' && row.perpetuity !== null) ? (row.perpetuity !== "Yes" ? {row.effective_from1} - {row.effective_to1} : `${row.effective_from1} - Perpetual`) : "" @@ -42,7 +41,7 @@ const columns = [ { id: 'link', label: 'Link', - Cell: (row: any) => ( + Cell: (row:any) => ( (row.cid === null || row.cid === 0 || row.effective_from1 === null) ? : (row.published === 1 @@ -55,82 +54,79 @@ const columns = [ }, ]; - -const ProjectTableHead = () => ( - - - {columns.map((column) => ( - - {column.label} - - ))} - - -); - -type Props = { - projectData: any; - page:any; - rowsPerPage:any -}; - -const ProjectTable = ({ projectData, page, rowsPerPage }:Props) => ( - - - {projectData && - projectData - .slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage) - .map((row:any) => ( - - {columns.map((column) => ( - { typeof row[column.id] === 'number' ? (row[column.id]) : row[column.id]} - ))} - - ))} - -
-); +type Props={ + projectData:any +} +export default function ProjectList({projectData}:Props) { + const [page, setPage] = React.useState(0); + const [rowsPerPage, setRowsPerPage] = React.useState(10); - -const ProjectList = ({ projectData}: any) => { - const [page, setPage] = useState(0); - const [rowsPerPage, setRowsPerPage] = useState(10); - - const handleChangePage = (event: any, newPage: React.SetStateAction) => { + const handleChangePage = (event:any, newPage:any) => { setPage(newPage); }; - const handleChangeRowsPerPage = (event: { target: { value: string | number; }; }) => { + const handleChangeRowsPerPage = (event:any) => { setRowsPerPage(+event.target.value); setPage(0); }; + return ( - - - - - - - - + + + + + + + {columns.map((column) => ( + + {column.label} + + ))} + + + + {projectData && projectData + .slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage) + .map((row:any) => { + return ( + + {columns.map((column:any) => { + const value = row[column.id]; + return ( + + {column.format && typeof value === 'number' + ? column.format(value) + : value} + + ); + })} + + ); + })} + +
+
+ +
); -}; - -export default ProjectList; \ No newline at end of file +} \ No newline at end of file