Refactor API call and types in AllTimeReportsInProjectOtherUser component
This commit is contained in:
parent
1b4e521508
commit
4d7b3e0d57
1 changed files with 6 additions and 36 deletions
|
@ -1,8 +1,9 @@
|
||||||
//Info: This component is used to display all the time reports for a project. It will display the week number,
|
//Info: This component is used to display all the time reports for a project. It will display the week number,
|
||||||
//total time spent, and if the report has been signed or not. The user can click on a report to edit it.
|
//total time spent, and if the report has been signed or not. The user can click on a report to edit it.
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { NewWeeklyReport } from "../Types/goTypes";
|
import { WeeklyReport } from "../Types/goTypes";
|
||||||
import { Link, useParams } from "react-router-dom";
|
import { Link, useParams } from "react-router-dom";
|
||||||
|
import { api } from "../API/API";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders a component that displays all the time reports for a specific project.
|
* Renders a component that displays all the time reports for a specific project.
|
||||||
|
@ -11,14 +12,14 @@ import { Link, useParams } from "react-router-dom";
|
||||||
function AllTimeReportsInProject(): JSX.Element {
|
function AllTimeReportsInProject(): JSX.Element {
|
||||||
const { username } = useParams();
|
const { username } = useParams();
|
||||||
const { projectName } = useParams();
|
const { projectName } = useParams();
|
||||||
const [weeklyReports, setWeeklyReports] = useState<NewWeeklyReport[]>([]);
|
const [weeklyReports, setWeeklyReports] = useState<WeeklyReport[]>([]);
|
||||||
|
|
||||||
/* // Call getProjects when the component mounts
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const getWeeklyReports = async (): Promise<void> => {
|
const getWeeklyReports = async (): Promise<void> => {
|
||||||
const token = localStorage.getItem("accessToken") ?? "";
|
const token = localStorage.getItem("accessToken") ?? "";
|
||||||
const response = await api.getWeeklyReportsForUser(
|
const response = await api.getWeeklyReportsForDifferentUser(
|
||||||
projectName ?? "",
|
projectName ?? "",
|
||||||
|
username ?? "",
|
||||||
token,
|
token,
|
||||||
);
|
);
|
||||||
console.log(response);
|
console.log(response);
|
||||||
|
@ -27,39 +28,8 @@ function AllTimeReportsInProject(): JSX.Element {
|
||||||
} else {
|
} else {
|
||||||
console.error(response.message);
|
console.error(response.message);
|
||||||
}
|
}
|
||||||
}; */
|
};
|
||||||
// Mock data
|
|
||||||
const getWeeklyReports = async (): Promise<void> => {
|
|
||||||
// Simulate a delay
|
|
||||||
await Promise.resolve();
|
|
||||||
const mockWeeklyReports: NewWeeklyReport[] = [
|
|
||||||
{
|
|
||||||
projectName: "Project 1",
|
|
||||||
week: 1,
|
|
||||||
developmentTime: 10,
|
|
||||||
meetingTime: 2,
|
|
||||||
adminTime: 1,
|
|
||||||
ownWorkTime: 3,
|
|
||||||
studyTime: 4,
|
|
||||||
testingTime: 5,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
projectName: "Project 1",
|
|
||||||
week: 2,
|
|
||||||
developmentTime: 8,
|
|
||||||
meetingTime: 2,
|
|
||||||
adminTime: 1,
|
|
||||||
ownWorkTime: 3,
|
|
||||||
studyTime: 4,
|
|
||||||
testingTime: 5,
|
|
||||||
},
|
|
||||||
// Add more reports as needed
|
|
||||||
];
|
|
||||||
|
|
||||||
// Use the mock data instead of the real data
|
|
||||||
setWeeklyReports(mockWeeklyReports);
|
|
||||||
};
|
|
||||||
useEffect(() => {
|
|
||||||
void getWeeklyReports();
|
void getWeeklyReports();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue