diff --git a/frontend/src/Components/LoginCheck.tsx b/frontend/src/Components/LoginCheck.tsx index ccf761d..af45d0f 100644 --- a/frontend/src/Components/LoginCheck.tsx +++ b/frontend/src/Components/LoginCheck.tsx @@ -1,30 +1,30 @@ -import { NewUser } from "../Types/Users"; +import { NewUser } from "../Types/goTypes"; function LoginCheck(props: { username: string; password: string }): number { //Example users for testing without backend, remove when using backend const admin: NewUser = { - userName: "admin", + username: "admin", password: "123", }; const pmanager: NewUser = { - userName: "pmanager", + username: "pmanager", password: "123", }; const user: NewUser = { - userName: "user", + username: "user", password: "123", }; //TODO: Compare with db instead when finished - if (props.username === admin.userName && props.password === admin.password) { + if (props.username === admin.username && props.password === admin.password) { return 1; } else if ( - props.username === pmanager.userName && + props.username === pmanager.username && props.password === pmanager.password ) { return 2; } else if ( - props.username === user.userName && + props.username === user.username && props.password === user.password ) { return 3; diff --git a/frontend/src/Components/ProjectListUser.tsx b/frontend/src/Components/ProjectListUser.tsx index 0502159..96eeaff 100644 --- a/frontend/src/Components/ProjectListUser.tsx +++ b/frontend/src/Components/ProjectListUser.tsx @@ -1,5 +1,5 @@ import { Link } from "react-router-dom"; -import { Project } from "../Types/Project"; +import { Project } from "../Types/goTypes"; /** * The props for the ProjectsProps component diff --git a/frontend/src/Components/Register.tsx b/frontend/src/Components/Register.tsx index 0c0fcd0..f3d773e 100644 --- a/frontend/src/Components/Register.tsx +++ b/frontend/src/Components/Register.tsx @@ -1,5 +1,5 @@ import { useState } from "react"; -import { NewUser } from "../Types/Users"; +import { NewUser } from "../Types/goTypes"; import { api } from "../API/API"; import Logo from "../assets/Logo.svg"; import Button from "./Button"; @@ -35,7 +35,7 @@ export default function Register(): JSX.Element { const [password, setPassword] = useState(""); const handleRegister = async (): Promise => { - const newUser: NewUser = { userName: username, password }; + const newUser: NewUser = { username: username, password }; await api.registerUser(newUser); // TODO: Handle errors }; diff --git a/frontend/src/Components/TimeReport.tsx b/frontend/src/Components/TimeReport.tsx index cb33ad9..e7eb5b7 100644 --- a/frontend/src/Components/TimeReport.tsx +++ b/frontend/src/Components/TimeReport.tsx @@ -1,40 +1,44 @@ import { useState } from "react"; -import { TimeReport } from "../Types/TimeReport"; import { api } from "../API/API"; import { useNavigate } from "react-router-dom"; import Button from "./Button"; +import { NewWeeklyReport } from "../Types/goTypes"; 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("projectName"); // TODO: Get from backend + const [week, setWeek] = useState(NaN); + const [development, setDevelopment] = useState(NaN); + const [meeting, setMeeting] = useState(NaN); + const [administration, setAdministration] = useState(NaN); + const [ownwork, setOwnWork] = useState(NaN); + const [studies, setStudies] = useState(NaN); + const [testing, setTesting] = useState(NaN); const handleNewTimeReport = async (): Promise => { - const newTimeReport: TimeReport = { + const newTimeReport: NewWeeklyReport = { + projectName, week, - development, - meeting, - administration, - ownwork, - studies, - testing, + developmentTime: development, + meetingTime: meeting, + adminTime: administration, + ownWorkTime: ownwork, + studyTime: studies, + testingTime: testing, }; await Promise.resolve(); - // await api.registerTimeReport(newTimeReport); This needs to be implemented! + await api.submitWeeklyReport(newTimeReport, "token"); }; const navigate = useNavigate(); + setProjectName("Something Reasonable"); // This should obviously not be used here + return ( <>
{ - if (week === "") { + if (!week) { alert("Please enter a week number"); e.preventDefault(); return; @@ -50,7 +54,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) => { @@ -81,7 +85,7 @@ export default function NewTimeReport(): JSX.Element { className="border-2 border-black rounded-md text-center w-1/2" value={development} onChange={(e) => { - setDevelopment(e.target.value); + setDevelopment(parseInt(e.target.value)); }} onKeyDown={(event) => { const keyValue = event.key; @@ -100,7 +104,7 @@ export default function NewTimeReport(): JSX.Element { className="border-2 border-black rounded-md text-center w-1/2" value={meeting} onChange={(e) => { - setMeeting(e.target.value); + setMeeting(parseInt(e.target.value)); }} onKeyDown={(event) => { const keyValue = event.key; @@ -119,7 +123,7 @@ export default function NewTimeReport(): JSX.Element { className="border-2 border-black rounded-md text-center w-1/2" value={administration} onChange={(e) => { - setAdministration(e.target.value); + setAdministration(parseInt(e.target.value)); }} onKeyDown={(event) => { const keyValue = event.key; @@ -138,7 +142,7 @@ export default function NewTimeReport(): JSX.Element { className="border-2 border-black rounded-md text-center w-1/2" value={ownwork} onChange={(e) => { - setOwnWork(e.target.value); + setOwnWork(parseInt(e.target.value)); }} onKeyDown={(event) => { const keyValue = event.key; @@ -157,7 +161,7 @@ export default function NewTimeReport(): JSX.Element { className="border-2 border-black rounded-md text-center w-1/2" value={studies} onChange={(e) => { - setStudies(e.target.value); + setStudies(parseInt(e.target.value)); }} onKeyDown={(event) => { const keyValue = event.key; @@ -176,7 +180,7 @@ export default function NewTimeReport(): JSX.Element { className="border-2 border-black rounded-md text-center w-1/2" value={testing} onChange={(e) => { - setTesting(e.target.value); + setTesting(parseInt(e.target.value)); }} onKeyDown={(event) => { const keyValue = event.key; diff --git a/frontend/src/Components/UserListAdmin.tsx b/frontend/src/Components/UserListAdmin.tsx index 42fb094..e25ad5f 100644 --- a/frontend/src/Components/UserListAdmin.tsx +++ b/frontend/src/Components/UserListAdmin.tsx @@ -1,5 +1,5 @@ import { Link } from "react-router-dom"; -import { User } from "../Types/Users"; +import { User } from "../Types/goTypes"; /** * The props for the UserProps component @@ -23,9 +23,9 @@ export function UserListAdmin(props: UserProps): JSX.Element {
    {props.users.map((user) => ( - -
  • - {user.userName} + +
  • + {user.username}
  • ))} diff --git a/frontend/src/Pages/UserPages/UserNewTimeReportPage.tsx b/frontend/src/Pages/UserPages/UserNewTimeReportPage.tsx index 85c80df..ca84770 100644 --- a/frontend/src/Pages/UserPages/UserNewTimeReportPage.tsx +++ b/frontend/src/Pages/UserPages/UserNewTimeReportPage.tsx @@ -1,7 +1,7 @@ import BasicWindow from "../../Components/BasicWindow"; import Button from "../../Components/Button"; import NewTimeReport from "../../Components/TimeReport"; -import BackButton from "../../Components/BackButton"; +import { Link } from "react-router-dom"; function UserNewTimeReportPage(): JSX.Element { const content = (