From 8cc0458e1b472d7f532c63fc0abb0eb647d1d38a Mon Sep 17 00:00:00 2001 From: Davenludd Date: Wed, 3 Apr 2024 17:44:26 +0200 Subject: [PATCH 1/5] Refactor API call in AllTimeReportsInProjectOtherUser component --- frontend/src/Components/AllTimeReportsInProjectOtherUser.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/Components/AllTimeReportsInProjectOtherUser.tsx b/frontend/src/Components/AllTimeReportsInProjectOtherUser.tsx index ef78642..570b94e 100644 --- a/frontend/src/Components/AllTimeReportsInProjectOtherUser.tsx +++ b/frontend/src/Components/AllTimeReportsInProjectOtherUser.tsx @@ -17,10 +17,10 @@ function AllTimeReportsInProject(): JSX.Element { useEffect(() => { const getWeeklyReports = async (): Promise => { const token = localStorage.getItem("accessToken") ?? ""; - const response = await api.getWeeklyReportsForDifferentUser( + const response = await api.getAllWeeklyReportsForUser( projectName ?? "", - username ?? "", token, + username ?? "", ); console.log(response); if (response.success) { From c0d36f8df163494e63870c6f368bb8bf0f1af90d Mon Sep 17 00:00:00 2001 From: Davenludd Date: Wed, 3 Apr 2024 18:05:07 +0200 Subject: [PATCH 2/5] Update API method to get all weekly reports --- frontend/src/Components/AllTimeReportsInProject.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/Components/AllTimeReportsInProject.tsx b/frontend/src/Components/AllTimeReportsInProject.tsx index 4fa9ad8..0d5916b 100644 --- a/frontend/src/Components/AllTimeReportsInProject.tsx +++ b/frontend/src/Components/AllTimeReportsInProject.tsx @@ -17,7 +17,7 @@ function AllTimeReportsInProject(): JSX.Element { useEffect(() => { const getWeeklyReports = async (): Promise => { const token = localStorage.getItem("accessToken") ?? ""; - const response = await api.getWeeklyReportsForUser( + const response = await api.getAllWeeklyReportsForUser( projectName ?? "", token, ); From be963b2281cfddad079582701766c114c8d06a60 Mon Sep 17 00:00:00 2001 From: Davenludd Date: Wed, 3 Apr 2024 18:05:19 +0200 Subject: [PATCH 3/5] Fix input fields to be read-only in OtherUsersTR and initialize state variables in TimePerRole --- frontend/src/Components/OtherUsersTR.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frontend/src/Components/OtherUsersTR.tsx b/frontend/src/Components/OtherUsersTR.tsx index 2b00e16..ce7761c 100644 --- a/frontend/src/Components/OtherUsersTR.tsx +++ b/frontend/src/Components/OtherUsersTR.tsx @@ -29,6 +29,7 @@ export default function OtherUsersTR(): JSX.Element { projectName ?? "", fetchedWeek?.toString() ?? "0", token, + username ?? "", ); if (response.success) { @@ -86,6 +87,7 @@ export default function OtherUsersTR(): JSX.Element { min="0" className="border-2 border-black rounded-md text-center w-1/2" value={developmentTime === 0 ? "" : developmentTime} + readOnly /> @@ -97,6 +99,7 @@ export default function OtherUsersTR(): JSX.Element { min="0" className="border-2 border-black rounded-md text-center w-1/2" value={meetingTime === 0 ? "" : meetingTime} + readOnly /> @@ -108,6 +111,7 @@ export default function OtherUsersTR(): JSX.Element { min="0" className="border-2 border-black rounded-md text-center w-1/2" value={adminTime === 0 ? "" : adminTime} + readOnly /> @@ -119,6 +123,7 @@ export default function OtherUsersTR(): JSX.Element { min="0" className="border-2 border-black rounded-md text-center w-1/2" value={ownWorkTime === 0 ? "" : ownWorkTime} + readOnly /> @@ -130,6 +135,7 @@ export default function OtherUsersTR(): JSX.Element { min="0" className="border-2 border-black rounded-md text-center w-1/2" value={studyTime === 0 ? "" : studyTime} + readOnly /> @@ -141,6 +147,7 @@ export default function OtherUsersTR(): JSX.Element { min="0" className="border-2 border-black rounded-md text-center w-1/2" value={testingTime === 0 ? "" : testingTime} + readOnly /> From 66a064c9f849bc162c9bc1b6da1617fb642aff57 Mon Sep 17 00:00:00 2001 From: Davenludd Date: Wed, 3 Apr 2024 18:05:30 +0200 Subject: [PATCH 4/5] Fix initial state values in TimePerRole component --- frontend/src/Components/TimePerActivity.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/src/Components/TimePerActivity.tsx b/frontend/src/Components/TimePerActivity.tsx index 6175845..c5e4a9f 100644 --- a/frontend/src/Components/TimePerActivity.tsx +++ b/frontend/src/Components/TimePerActivity.tsx @@ -8,12 +8,12 @@ import { projectTimes } from "./GetProjectTimes"; * @returns JSX.Element */ export default function TimePerRole(): JSX.Element { - const [development, setDevelopment] = useState(); - const [meeting, setMeeting] = useState(); - const [admin, setAdmin] = useState(); - const [own_work, setOwnWork] = useState(); - const [study, setStudy] = useState(); - const [testing, setTesting] = useState(); + const [development, setDevelopment] = useState(0); + const [meeting, setMeeting] = useState(0); + const [admin, setAdmin] = useState(0); + const [own_work, setOwnWork] = useState(0); + const [study, setStudy] = useState(0); + const [testing, setTesting] = useState(0); const token = localStorage.getItem("accessToken") ?? ""; const { projectName } = useParams(); From a0ff329845f24ff67774005ee43a285f19ff4a61 Mon Sep 17 00:00:00 2001 From: Davenludd Date: Wed, 3 Apr 2024 18:36:17 +0200 Subject: [PATCH 5/5] Update useEffect dependencies in AllTimeReportsInProjectOtherUser component --- frontend/src/Components/AllTimeReportsInProjectOtherUser.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/Components/AllTimeReportsInProjectOtherUser.tsx b/frontend/src/Components/AllTimeReportsInProjectOtherUser.tsx index 570b94e..cde9fa7 100644 --- a/frontend/src/Components/AllTimeReportsInProjectOtherUser.tsx +++ b/frontend/src/Components/AllTimeReportsInProjectOtherUser.tsx @@ -31,7 +31,7 @@ function AllTimeReportsInProject(): JSX.Element { }; void getWeeklyReports(); - }, []); + }, [projectName, username]); return ( <>