Fixes in NewWeeklyReport component

This commit is contained in:
Davenludd 2024-03-18 21:40:07 +01:00
parent 847180cf75
commit 93addc9870

View file

@ -1,9 +1,8 @@
import { useState, useContext } from "react";
import { useState } from "react";
import { NewWeeklyReport } from "../Types/goTypes";
import { api } from "../API/API";
import { useNavigate } from "react-router-dom";
import { useNavigate, useParams } from "react-router-dom";
import Button from "./Button";
import { ProjectNameContext } from "../Pages/YourProjectsPage";
export default function NewWeeklyReport(): JSX.Element {
const [week, setWeek] = useState(0);
@ -14,12 +13,12 @@ export default function NewWeeklyReport(): JSX.Element {
const [studyTime, setStudyTime] = useState(0);
const [testingTime, setTestingTime] = useState(0);
const projectName = useContext(ProjectNameContext);
const { projectName } = useParams();
const token = localStorage.getItem("accessToken") ?? "";
const handleNewWeeklyReport = async (): Promise<void> => {
const newWeeklyReport: NewWeeklyReport = {
projectName,
projectName: projectName ?? "",
week,
developmentTime,
meetingTime,
@ -46,7 +45,7 @@ export default function NewWeeklyReport(): JSX.Element {
}
e.preventDefault();
void handleNewWeeklyReport();
navigate("/project");
navigate(-1);
}}
>
<div className="flex flex-col items-center">