import { useState, useEffect } from "react"; import { WeeklyReport } from "../Types/goTypes"; import { api } from "../API/API"; import { useParams } from "react-router-dom"; /** * Renders the component for editing a weekly report. * @returns JSX.Element */ //This component does not yet work as intended. It is supposed to display the weekly report of a user in a project. export default function OtherUsersTR(): JSX.Element { const [week, setWeek] = useState(0); const [developmentTime, setDevelopmentTime] = useState(0); const [meetingTime, setMeetingTime] = useState(0); const [adminTime, setAdminTime] = useState(0); const [ownWorkTime, setOwnWorkTime] = useState(0); const [studyTime, setStudyTime] = useState(0); const [testingTime, setTestingTime] = useState(0); const token = localStorage.getItem("accessToken") ?? ""; const { projectName } = useParams(); const { username } = useParams(); const { fetchedWeek } = useParams(); useEffect(() => { const fetchUsersWeeklyReport = async (): Promise => { const response = await api.getWeeklyReport( projectName ?? "", fetchedWeek?.toString() ?? "0", token, ); if (response.success) { const report: WeeklyReport = response.data ?? { reportId: 0, userId: 0, projectId: 0, week: 0, developmentTime: 0, meetingTime: 0, adminTime: 0, ownWorkTime: 0, studyTime: 0, testingTime: 0, }; setWeek(report.week); setDevelopmentTime(report.developmentTime); setMeetingTime(report.meetingTime); setAdminTime(report.adminTime); setOwnWorkTime(report.ownWorkTime); setStudyTime(report.studyTime); setTestingTime(report.testingTime); } else { console.error("Failed to fetch weekly report:", response.message); } }; void fetchUsersWeeklyReport(); }); return ( <>

{username}'s Report

Week: {week}

Activity Total Time (min)
Development
Meeting
Administration
Own Work
Studies
Testing
); }