Refactor fetchWeeklyReport in EditWeeklyReport component

This commit is contained in:
Davenludd 2024-03-28 12:09:09 +01:00
parent 7c73a01d4c
commit 48e4d1a8df

View file

@ -18,13 +18,17 @@ export default function GetWeeklyReport(): JSX.Element {
const [testingTime, setTestingTime] = useState(0);
const token = localStorage.getItem("accessToken") ?? "";
const { projectName } = useParams();
const { fetchedWeek } = useParams();
const { projectName, fetchedWeek } = useParams<{
projectName: string;
fetchedWeek: string;
}>();
console.log(projectName, fetchedWeek);
useEffect(() => {
const fetchWeeklyReport = async (): Promise<void> => {
const response = await api.getWeeklyReport(
projectName ?? "",
fetchedWeek?.toString() ?? "0",
fetchedWeek ?? "",
token,
);
@ -53,9 +57,8 @@ export default function GetWeeklyReport(): JSX.Element {
}
};
useEffect(() => {
void fetchWeeklyReport();
});
}, [projectName, fetchedWeek, token]);
const handleNewWeeklyReport = async (): Promise<void> => {
const newWeeklyReport: NewWeeklyReport = {