import { useState, useEffect } from "react"; import { Link, useParams } from "react-router-dom"; import { api } from "../API/API"; import { WeeklyReport } from "../Types/goTypes"; /** * Renders a component that displays the projects a user is a part of and links to the projects start-page. * @returns The JSX element representing the component. */ function DisplayUserProject(): JSX.Element { const { projectName } = useParams(); const [unsignedReports, setUnsignedReports] = useState([]); //const navigate = useNavigate(); useEffect(() => { const getUnsignedReports = async (): Promise => { const token = localStorage.getItem("accessToken") ?? ""; const response = await api.getUnsignedReportsInProject( projectName ?? "", token, ); console.log(response); if (response.success) { setUnsignedReports(response.data ?? []); } else { console.error(response.message); } }; void getUnsignedReports(); }, [projectName]); // Include 'projectName' in the dependency array return ( <>

All Unsigned Reports In: {projectName}{" "}

{unsignedReports.map((unsignedReport: WeeklyReport, index: number) => (

UserID:

{unsignedReport.userId}

Week:

{unsignedReport.week}

Total Time:

{unsignedReport.developmentTime + unsignedReport.meetingTime + unsignedReport.adminTime + unsignedReport.ownWorkTime + unsignedReport.studyTime + unsignedReport.testingTime}

Signed:

NO

View Report

))}
); } export default DisplayUserProject;