diff --git a/frontend/src/Components/TimeReport.tsx b/frontend/src/Components/NewWeeklyReport.tsx similarity index 80% rename from frontend/src/Components/TimeReport.tsx rename to frontend/src/Components/NewWeeklyReport.tsx index cb33ad9..1f613ac 100644 --- a/frontend/src/Components/TimeReport.tsx +++ b/frontend/src/Components/NewWeeklyReport.tsx @@ -1,30 +1,32 @@ import { useState } from "react"; -import { TimeReport } from "../Types/TimeReport"; +import { NewWeeklyReport } from "../Types/goTypes"; import { api } from "../API/API"; import { useNavigate } from "react-router-dom"; import Button from "./Button"; export default function NewTimeReport(): JSX.Element { - const [week, setWeek] = useState(""); - const [development, setDevelopment] = useState("0"); - const [meeting, setMeeting] = useState("0"); - const [administration, setAdministration] = useState("0"); - const [ownwork, setOwnWork] = useState("0"); - const [studies, setStudies] = useState("0"); - const [testing, setTesting] = useState("0"); + const [projectName, setProjectName] = useState(""); + const [week, setWeek] = useState(0); + const [developmentTime, setDevelopmentTime] = useState(0); + const [meetingTime, setMeetingTime] = useState(0); + const [adminTime, setAdminTime] = useState(0); + const [ownWorkTime, setOwnWorkTime] = useState(0); + const [studyTime, setStudyTime] = useState(0); + const [testingTime, setTestingTime] = useState(0); const handleNewTimeReport = async (): Promise => { - const newTimeReport: TimeReport = { + const newTimeReport: NewWeeklyReport = { + projectName, week, - development, - meeting, - administration, - ownwork, - studies, - testing, + developmentTime, + meetingTime, + adminTime, + ownWorkTime, + studyTime, + testingTime, }; await Promise.resolve(); - // await api.registerTimeReport(newTimeReport); This needs to be implemented! + // await api.submitWeeklyReport(newTimeReport, token); Token is not defined yet }; const navigate = useNavigate(); @@ -34,7 +36,7 @@ export default function NewTimeReport(): JSX.Element {
{ - if (week === "") { + if (week === 0) { alert("Please enter a week number"); e.preventDefault(); return; @@ -50,7 +52,7 @@ export default function NewTimeReport(): JSX.Element { type="week" placeholder="Week" onChange={(e) => { - const weekNumber = e.target.value.split("-W")[1]; + const weekNumber = parseInt(e.target.value.split("-W")[1]); setWeek(weekNumber); }} onKeyDown={(event) => { @@ -79,9 +81,9 @@ export default function NewTimeReport(): JSX.Element { type="number" min="0" className="border-2 border-black rounded-md text-center w-1/2" - value={development} + value={developmentTime} onChange={(e) => { - setDevelopment(e.target.value); + setDevelopmentTime(parseInt(e.target.value)); }} onKeyDown={(event) => { const keyValue = event.key; @@ -98,9 +100,9 @@ export default function NewTimeReport(): JSX.Element { type="number" min="0" className="border-2 border-black rounded-md text-center w-1/2" - value={meeting} + value={meetingTime} onChange={(e) => { - setMeeting(e.target.value); + setMeetingTime(parseInt(e.target.value)); }} onKeyDown={(event) => { const keyValue = event.key; @@ -117,9 +119,9 @@ export default function NewTimeReport(): JSX.Element { type="number" min="0" className="border-2 border-black rounded-md text-center w-1/2" - value={administration} + value={adminTime} onChange={(e) => { - setAdministration(e.target.value); + setAdminTime(parseInt(e.target.value)); }} onKeyDown={(event) => { const keyValue = event.key; @@ -136,9 +138,9 @@ export default function NewTimeReport(): JSX.Element { type="number" min="0" className="border-2 border-black rounded-md text-center w-1/2" - value={ownwork} + value={ownWorkTime} onChange={(e) => { - setOwnWork(e.target.value); + setOwnWorkTime(parseInt(e.target.value)); }} onKeyDown={(event) => { const keyValue = event.key; @@ -155,9 +157,9 @@ export default function NewTimeReport(): JSX.Element { type="number" min="0" className="border-2 border-black rounded-md text-center w-1/2" - value={studies} + value={studyTime} onChange={(e) => { - setStudies(e.target.value); + setStudyTime(parseInt(e.target.value)); }} onKeyDown={(event) => { const keyValue = event.key; @@ -174,9 +176,9 @@ export default function NewTimeReport(): JSX.Element { type="number" min="0" className="border-2 border-black rounded-md text-center w-1/2" - value={testing} + value={testingTime} onChange={(e) => { - setTesting(e.target.value); + setTestingTime(parseInt(e.target.value)); }} onKeyDown={(event) => { const keyValue = event.key; diff --git a/frontend/src/Pages/ProjectManagerPages/PMTotalTimeActivity.tsx b/frontend/src/Pages/ProjectManagerPages/PMTotalTimeActivity.tsx index 5ae5a4b..63e623a 100644 --- a/frontend/src/Pages/ProjectManagerPages/PMTotalTimeActivity.tsx +++ b/frontend/src/Pages/ProjectManagerPages/PMTotalTimeActivity.tsx @@ -1,6 +1,6 @@ import BasicWindow from "../../Components/BasicWindow"; import Button from "../../Components/Button"; -import TimeReport from "../../Components/TimeReport"; +import TimeReport from "../../Components/NewWeeklyReport"; function PMTotalTimeActivity(): JSX.Element { const content = ( diff --git a/frontend/src/Pages/ProjectManagerPages/PMViewUnsignedReport.tsx b/frontend/src/Pages/ProjectManagerPages/PMViewUnsignedReport.tsx index 8bf9143..f9d5998 100644 --- a/frontend/src/Pages/ProjectManagerPages/PMViewUnsignedReport.tsx +++ b/frontend/src/Pages/ProjectManagerPages/PMViewUnsignedReport.tsx @@ -1,6 +1,6 @@ import BasicWindow from "../../Components/BasicWindow"; import Button from "../../Components/Button"; -import TimeReport from "../../Components/TimeReport"; +import TimeReport from "../../Components/NewWeeklyReport"; function PMViewUnsignedReport(): JSX.Element { const content = ( diff --git a/frontend/src/Pages/UserPages/UserEditTimeReportPage.tsx b/frontend/src/Pages/UserPages/UserEditTimeReportPage.tsx index af3bbc1..97e49e3 100644 --- a/frontend/src/Pages/UserPages/UserEditTimeReportPage.tsx +++ b/frontend/src/Pages/UserPages/UserEditTimeReportPage.tsx @@ -1,6 +1,6 @@ import BasicWindow from "../../Components/BasicWindow"; import Button from "../../Components/Button"; -import NewTimeReport from "../../Components/TimeReport"; +import NewTimeReport from "../../Components/NewWeeklyReport"; function UserEditTimeReportPage(): JSX.Element { const content = ( diff --git a/frontend/src/Pages/UserPages/UserNewTimeReportPage.tsx b/frontend/src/Pages/UserPages/UserNewTimeReportPage.tsx index ca84770..d4db5a4 100644 --- a/frontend/src/Pages/UserPages/UserNewTimeReportPage.tsx +++ b/frontend/src/Pages/UserPages/UserNewTimeReportPage.tsx @@ -1,6 +1,6 @@ import BasicWindow from "../../Components/BasicWindow"; import Button from "../../Components/Button"; -import NewTimeReport from "../../Components/TimeReport"; +import NewTimeReport from "../../Components/NewWeeklyReport"; import { Link } from "react-router-dom"; function UserNewTimeReportPage(): JSX.Element {