110 lines
3.1 KiB
TypeScript
110 lines
3.1 KiB
TypeScript
|
import React, { useEffect, useState } from "react";
|
||
|
import { NewWeeklyReport } from "../Types/goTypes";
|
||
|
import { Link, useParams } from "react-router-dom";
|
||
|
|
||
|
function AllTimeReportsInProject(): JSX.Element {
|
||
|
const { projectName } = useParams();
|
||
|
const [weeklyReports, setWeeklyReports] = useState<NewWeeklyReport[]>([]);
|
||
|
|
||
|
/* const getWeeklyReports = async (): Promise<void> => {
|
||
|
const token = localStorage.getItem("accessToken") ?? "";
|
||
|
const response = await api.getWeeklyReports(token);
|
||
|
console.log(response);
|
||
|
if (response.success) {
|
||
|
setWeeklyReports(response.data ?? []);
|
||
|
} else {
|
||
|
console.error(response.message);
|
||
|
}
|
||
|
}; */
|
||
|
|
||
|
const getWeeklyReports = async (): Promise<void> => {
|
||
|
const report: NewWeeklyReport[] = [
|
||
|
{
|
||
|
projectName: projectName ?? "",
|
||
|
week: 10,
|
||
|
developmentTime: 1,
|
||
|
meetingTime: 1,
|
||
|
adminTime: 1,
|
||
|
ownWorkTime: 1,
|
||
|
studyTime: 1,
|
||
|
testingTime: 1,
|
||
|
},
|
||
|
{
|
||
|
projectName: projectName ?? "",
|
||
|
week: 11,
|
||
|
developmentTime: 1,
|
||
|
meetingTime: 1,
|
||
|
adminTime: 1,
|
||
|
ownWorkTime: 100,
|
||
|
studyTime: 1,
|
||
|
testingTime: 1,
|
||
|
},
|
||
|
{
|
||
|
projectName: projectName ?? "",
|
||
|
week: 12,
|
||
|
developmentTime: 1,
|
||
|
meetingTime: 1,
|
||
|
adminTime: 1,
|
||
|
ownWorkTime: 1,
|
||
|
studyTime: 1,
|
||
|
testingTime: 1000,
|
||
|
},
|
||
|
{
|
||
|
projectName: projectName ?? "",
|
||
|
week: 20,
|
||
|
developmentTime: 1,
|
||
|
meetingTime: 1,
|
||
|
adminTime: 1,
|
||
|
ownWorkTime: 1,
|
||
|
studyTime: 1,
|
||
|
testingTime: 10000,
|
||
|
},
|
||
|
// Add more reports as needed
|
||
|
];
|
||
|
setWeeklyReports(report);
|
||
|
await Promise.resolve();
|
||
|
};
|
||
|
|
||
|
// Call getProjects when the component mounts
|
||
|
useEffect(() => {
|
||
|
void getWeeklyReports();
|
||
|
}, []);
|
||
|
|
||
|
return (
|
||
|
<>
|
||
|
<div className="border-4 border-black bg-white flex flex-col items-center justify-center min-h-[65vh] h-fit w-[50vw] rounded-3xl content-center overflow-scroll space-y-[10vh] p-[30px] text-[30px]">
|
||
|
{weeklyReports.map((newWeeklyReport, index) => (
|
||
|
<Link
|
||
|
to={`/editTimeReport/${projectName}/${newWeeklyReport.week}`}
|
||
|
key={index}
|
||
|
className="border-b-2 border-black w-full"
|
||
|
>
|
||
|
<div className="flex justify-between">
|
||
|
<h1>
|
||
|
<span className="font-bold">{"Week: "}</span>
|
||
|
{newWeeklyReport.week}
|
||
|
</h1>
|
||
|
<h1>
|
||
|
<span className="font-bold">{"Total Time: "}</span>
|
||
|
{newWeeklyReport.developmentTime +
|
||
|
newWeeklyReport.meetingTime +
|
||
|
newWeeklyReport.adminTime +
|
||
|
newWeeklyReport.ownWorkTime +
|
||
|
newWeeklyReport.studyTime +
|
||
|
newWeeklyReport.testingTime}{" "}
|
||
|
min
|
||
|
</h1>
|
||
|
<h1>
|
||
|
<span className="font-bold">{"Signed: "}</span>
|
||
|
YES
|
||
|
</h1>
|
||
|
</div>
|
||
|
</Link>
|
||
|
))}
|
||
|
</div>
|
||
|
</>
|
||
|
);
|
||
|
}
|
||
|
|
||
|
export default AllTimeReportsInProject;
|