import { useState, useEffect } from "react"; import { Link, useParams } from "react-router-dom"; interface UnsignedReports { projectName: string; username: string; week: number; signed: boolean; } /** * 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(); // const getUnsignedReports = async (): Promise => { // const token = localStorage.getItem("accessToken") ?? ""; // const response = await api.getUserProjects(token); // console.log(response); // if (response.success) { // setUnsignedReports(response.data ?? []); // } else { // console.error(response.message); // } // }; // const handleReportClick = async (projectName: string): Promise => { // const username = localStorage.getItem("username") ?? ""; // const token = localStorage.getItem("accessToken") ?? ""; // const response = await api.checkIfProjectManager( // username, // projectName, // token, // ); // if (response.success) { // if (response.data) { // navigate(`/PMProjectPage/${projectName}`); // } else { // navigate(`/project/${projectName}`); // } // } else { // // handle error // console.error(response.message); // } // }; const getUnsignedReports = async (): Promise => { // Simulate a delay await Promise.resolve(); // Use mock data const reports: UnsignedReports[] = [ { projectName: "projecttest", username: "user1", week: 2, signed: false, }, { projectName: "projecttest", username: "user2", week: 2, signed: false, }, { projectName: "projecttest", username: "user3", week: 2, signed: false, }, { projectName: "projecttest", username: "user4", week: 2, signed: false, }, ]; // Set the state with the mock data setUnsignedReports(reports); }; // Call getProjects when the component mounts useEffect(() => { void getUnsignedReports(); }, []); return ( <>

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

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

{unsignedReport.username}

Week:

{unsignedReport.week}

Signed:

NO

View Report

), )}
); } export default DisplayUserProject;