2024-03-21 12:10:43 +01:00
|
|
|
import { useState, useEffect } from "react";
|
|
|
|
import { Link, useParams } from "react-router-dom";
|
2024-04-02 17:05:55 +02:00
|
|
|
import { api } from "../API/API";
|
|
|
|
import { WeeklyReport } from "../Types/goTypes";
|
2024-03-21 12:10:43 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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();
|
2024-04-02 17:05:55 +02:00
|
|
|
const [unsignedReports, setUnsignedReports] = useState<WeeklyReport[]>([]);
|
2024-03-21 12:10:43 +01:00
|
|
|
//const navigate = useNavigate();
|
|
|
|
useEffect(() => {
|
2024-04-02 17:07:47 +02:00
|
|
|
const getUnsignedReports = async (): Promise<void> => {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-03-21 12:10:43 +01:00
|
|
|
void getUnsignedReports();
|
2024-04-02 17:07:47 +02:00
|
|
|
}, [projectName]); // Include 'projectName' in the dependency array
|
2024-03-21 12:10:43 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<h1 className="font-bold text-[30px] mb-[20px]">
|
|
|
|
All Unsigned Reports In: {projectName}{" "}
|
|
|
|
</h1>
|
|
|
|
<div className="border-4 border-black bg-white flex flex-col items-center justify-center min-h-[65vh] h-fit w-[70vw] rounded-3xl content-center overflow-scroll space-y-[10vh] p-[30px] text-[20px]">
|
2024-04-02 17:05:55 +02:00
|
|
|
{unsignedReports.map((unsignedReport: WeeklyReport, index: number) => (
|
|
|
|
<h1 key={index} className="border-b-2 border-black w-full">
|
|
|
|
<div className="flex justify-between">
|
|
|
|
<div className="flex">
|
|
|
|
<span className="ml-6 mr-2 font-bold">UserID:</span>
|
|
|
|
<h1>{unsignedReport.userId}</h1>
|
|
|
|
<span className="ml-6 mr-2 font-bold">Week:</span>
|
|
|
|
<h1>{unsignedReport.week}</h1>
|
2024-04-02 17:33:20 +02:00
|
|
|
<span className="ml-6 mr-2 font-bold">Total Time:</span>
|
|
|
|
<h1>
|
|
|
|
{unsignedReport.developmentTime +
|
|
|
|
unsignedReport.meetingTime +
|
|
|
|
unsignedReport.adminTime +
|
|
|
|
unsignedReport.ownWorkTime +
|
|
|
|
unsignedReport.studyTime +
|
|
|
|
unsignedReport.testingTime}
|
|
|
|
</h1>
|
2024-04-02 17:05:55 +02:00
|
|
|
<span className="ml-6 mr-2 font-bold">Signed:</span>
|
|
|
|
<h1>NO</h1>
|
|
|
|
</div>
|
|
|
|
<div className="flex">
|
|
|
|
<div className="ml-auto flex space-x-4">
|
|
|
|
<Link
|
|
|
|
to={`/PMViewUnsignedReport/${projectName}/${unsignedReport.userId}/${unsignedReport.week}`}
|
|
|
|
>
|
|
|
|
<h1 className="underline cursor-pointer font-bold">
|
|
|
|
View Report
|
|
|
|
</h1>
|
|
|
|
</Link>
|
2024-03-21 12:10:43 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-04-02 17:05:55 +02:00
|
|
|
</div>
|
|
|
|
</h1>
|
|
|
|
))}
|
2024-03-21 12:10:43 +01:00
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default DisplayUserProject;
|