import { useState, useEffect } from "react"; import { useParams } from "react-router-dom"; /** * Renders the component for showing total time per role in a project. * @returns JSX.Element */ export default function TimePerRole(): JSX.Element { const [PManagerTime, setPManagerTime] = useState(0); const [SManagerTime, setSManagerTime] = useState(0); const [DeveloperTime, setDeveloperTime] = useState(0); const [TesterTime, setTesterTime] = useState(0); // const token = localStorage.getItem("accessToken") ?? ""; // const username = localStorage.getItem("username") ?? ""; const { projectName } = useParams(); // const fetchTimePerRole = async (): Promise => { // const response = await api.getTimePerRole( // username, // projectName ?? "", // token, // ); // { // if (response.success) { // const report: TimePerRole = response.data ?? { // PManagerTime: 0, // SManagerTime: 0, // DeveloperTime: 0, // TesterTime: 0, // }; // } else { // console.error("Failed to fetch weekly report:", response.message); // } // } interface TimePerRole { PManager: number; SManager: number; Developer: number; Tester: number; } const fetchTimePerRole = async (): Promise => { // Use mock data const report: TimePerRole = { PManager: 120, SManager: 80, Developer: 200, Tester: 150, }; // Set the state with the mock data setPManagerTime(report.PManager); setSManagerTime(report.SManager); setDeveloperTime(report.Developer); setTesterTime(report.Tester); await Promise.resolve(); }; useEffect(() => { void fetchTimePerRole(); }); return ( <>

Total Time Per Role In: {projectName}{" "}

Role Total Time (min)
Project Manager { event.preventDefault(); }} />
System Manager { event.preventDefault(); }} />
Administration { event.preventDefault(); }} />
Own Work { event.preventDefault(); }} />
); }