Making linter bro happy
This commit is contained in:
parent
d57fe55074
commit
30cf0b6065
6 changed files with 43 additions and 39 deletions
|
@ -1,30 +1,30 @@
|
||||||
import { NewUser } from "../Types/Users";
|
import { NewUser } from "../Types/goTypes";
|
||||||
|
|
||||||
function LoginCheck(props: { username: string; password: string }): number {
|
function LoginCheck(props: { username: string; password: string }): number {
|
||||||
//Example users for testing without backend, remove when using backend
|
//Example users for testing without backend, remove when using backend
|
||||||
const admin: NewUser = {
|
const admin: NewUser = {
|
||||||
userName: "admin",
|
username: "admin",
|
||||||
password: "123",
|
password: "123",
|
||||||
};
|
};
|
||||||
const pmanager: NewUser = {
|
const pmanager: NewUser = {
|
||||||
userName: "pmanager",
|
username: "pmanager",
|
||||||
password: "123",
|
password: "123",
|
||||||
};
|
};
|
||||||
const user: NewUser = {
|
const user: NewUser = {
|
||||||
userName: "user",
|
username: "user",
|
||||||
password: "123",
|
password: "123",
|
||||||
};
|
};
|
||||||
|
|
||||||
//TODO: Compare with db instead when finished
|
//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;
|
return 1;
|
||||||
} else if (
|
} else if (
|
||||||
props.username === pmanager.userName &&
|
props.username === pmanager.username &&
|
||||||
props.password === pmanager.password
|
props.password === pmanager.password
|
||||||
) {
|
) {
|
||||||
return 2;
|
return 2;
|
||||||
} else if (
|
} else if (
|
||||||
props.username === user.userName &&
|
props.username === user.username &&
|
||||||
props.password === user.password
|
props.password === user.password
|
||||||
) {
|
) {
|
||||||
return 3;
|
return 3;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { Project } from "../Types/Project";
|
import { Project } from "../Types/goTypes";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The props for the ProjectsProps component
|
* The props for the ProjectsProps component
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { NewUser } from "../Types/Users";
|
import { NewUser } from "../Types/goTypes";
|
||||||
import { api } from "../API/API";
|
import { api } from "../API/API";
|
||||||
import Logo from "../assets/Logo.svg";
|
import Logo from "../assets/Logo.svg";
|
||||||
import Button from "./Button";
|
import Button from "./Button";
|
||||||
|
@ -35,7 +35,7 @@ export default function Register(): JSX.Element {
|
||||||
const [password, setPassword] = useState("");
|
const [password, setPassword] = useState("");
|
||||||
|
|
||||||
const handleRegister = async (): Promise<void> => {
|
const handleRegister = async (): Promise<void> => {
|
||||||
const newUser: NewUser = { userName: username, password };
|
const newUser: NewUser = { username: username, password };
|
||||||
await api.registerUser(newUser); // TODO: Handle errors
|
await api.registerUser(newUser); // TODO: Handle errors
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,40 +1,44 @@
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { TimeReport } from "../Types/TimeReport";
|
|
||||||
import { api } from "../API/API";
|
import { api } from "../API/API";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import Button from "./Button";
|
import Button from "./Button";
|
||||||
|
import { NewWeeklyReport } from "../Types/goTypes";
|
||||||
|
|
||||||
export default function NewTimeReport(): JSX.Element {
|
export default function NewTimeReport(): JSX.Element {
|
||||||
const [week, setWeek] = useState("");
|
const [projectName, setProjectName] = useState<string>("projectName"); // TODO: Get from backend
|
||||||
const [development, setDevelopment] = useState("0");
|
const [week, setWeek] = useState<number>(NaN);
|
||||||
const [meeting, setMeeting] = useState("0");
|
const [development, setDevelopment] = useState<number>(NaN);
|
||||||
const [administration, setAdministration] = useState("0");
|
const [meeting, setMeeting] = useState<number>(NaN);
|
||||||
const [ownwork, setOwnWork] = useState("0");
|
const [administration, setAdministration] = useState<number>(NaN);
|
||||||
const [studies, setStudies] = useState("0");
|
const [ownwork, setOwnWork] = useState<number>(NaN);
|
||||||
const [testing, setTesting] = useState("0");
|
const [studies, setStudies] = useState<number>(NaN);
|
||||||
|
const [testing, setTesting] = useState<number>(NaN);
|
||||||
|
|
||||||
const handleNewTimeReport = async (): Promise<void> => {
|
const handleNewTimeReport = async (): Promise<void> => {
|
||||||
const newTimeReport: TimeReport = {
|
const newTimeReport: NewWeeklyReport = {
|
||||||
|
projectName,
|
||||||
week,
|
week,
|
||||||
development,
|
developmentTime: development,
|
||||||
meeting,
|
meetingTime: meeting,
|
||||||
administration,
|
adminTime: administration,
|
||||||
ownwork,
|
ownWorkTime: ownwork,
|
||||||
studies,
|
studyTime: studies,
|
||||||
testing,
|
testingTime: testing,
|
||||||
};
|
};
|
||||||
await Promise.resolve();
|
await Promise.resolve();
|
||||||
// await api.registerTimeReport(newTimeReport); This needs to be implemented!
|
await api.submitWeeklyReport(newTimeReport, "token");
|
||||||
};
|
};
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
setProjectName("Something Reasonable"); // This should obviously not be used here
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="border-4 border-black bg-white flex flex-col justify-start min-h-[65vh] h-fit w-[50vw] rounded-3xl overflow-scroll space-y-[2vh] p-[30px] items-center">
|
<div className="border-4 border-black bg-white flex flex-col justify-start min-h-[65vh] h-fit w-[50vw] rounded-3xl overflow-scroll space-y-[2vh] p-[30px] items-center">
|
||||||
<form
|
<form
|
||||||
onSubmit={(e) => {
|
onSubmit={(e) => {
|
||||||
if (week === "") {
|
if (!week) {
|
||||||
alert("Please enter a week number");
|
alert("Please enter a week number");
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return;
|
return;
|
||||||
|
@ -50,7 +54,7 @@ export default function NewTimeReport(): JSX.Element {
|
||||||
type="week"
|
type="week"
|
||||||
placeholder="Week"
|
placeholder="Week"
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const weekNumber = e.target.value.split("-W")[1];
|
const weekNumber = parseInt(e.target.value.split("-W")[1]);
|
||||||
setWeek(weekNumber);
|
setWeek(weekNumber);
|
||||||
}}
|
}}
|
||||||
onKeyDown={(event) => {
|
onKeyDown={(event) => {
|
||||||
|
@ -81,7 +85,7 @@ export default function NewTimeReport(): JSX.Element {
|
||||||
className="border-2 border-black rounded-md text-center w-1/2"
|
className="border-2 border-black rounded-md text-center w-1/2"
|
||||||
value={development}
|
value={development}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setDevelopment(e.target.value);
|
setDevelopment(parseInt(e.target.value));
|
||||||
}}
|
}}
|
||||||
onKeyDown={(event) => {
|
onKeyDown={(event) => {
|
||||||
const keyValue = event.key;
|
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"
|
className="border-2 border-black rounded-md text-center w-1/2"
|
||||||
value={meeting}
|
value={meeting}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setMeeting(e.target.value);
|
setMeeting(parseInt(e.target.value));
|
||||||
}}
|
}}
|
||||||
onKeyDown={(event) => {
|
onKeyDown={(event) => {
|
||||||
const keyValue = event.key;
|
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"
|
className="border-2 border-black rounded-md text-center w-1/2"
|
||||||
value={administration}
|
value={administration}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setAdministration(e.target.value);
|
setAdministration(parseInt(e.target.value));
|
||||||
}}
|
}}
|
||||||
onKeyDown={(event) => {
|
onKeyDown={(event) => {
|
||||||
const keyValue = event.key;
|
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"
|
className="border-2 border-black rounded-md text-center w-1/2"
|
||||||
value={ownwork}
|
value={ownwork}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setOwnWork(e.target.value);
|
setOwnWork(parseInt(e.target.value));
|
||||||
}}
|
}}
|
||||||
onKeyDown={(event) => {
|
onKeyDown={(event) => {
|
||||||
const keyValue = event.key;
|
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"
|
className="border-2 border-black rounded-md text-center w-1/2"
|
||||||
value={studies}
|
value={studies}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setStudies(e.target.value);
|
setStudies(parseInt(e.target.value));
|
||||||
}}
|
}}
|
||||||
onKeyDown={(event) => {
|
onKeyDown={(event) => {
|
||||||
const keyValue = event.key;
|
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"
|
className="border-2 border-black rounded-md text-center w-1/2"
|
||||||
value={testing}
|
value={testing}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setTesting(e.target.value);
|
setTesting(parseInt(e.target.value));
|
||||||
}}
|
}}
|
||||||
onKeyDown={(event) => {
|
onKeyDown={(event) => {
|
||||||
const keyValue = event.key;
|
const keyValue = event.key;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { User } from "../Types/Users";
|
import { User } from "../Types/goTypes";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The props for the UserProps component
|
* The props for the UserProps component
|
||||||
|
@ -23,9 +23,9 @@ export function UserListAdmin(props: UserProps): JSX.Element {
|
||||||
<div>
|
<div>
|
||||||
<ul className="font-bold underline text-[30px] cursor-pointer padding">
|
<ul className="font-bold underline text-[30px] cursor-pointer padding">
|
||||||
{props.users.map((user) => (
|
{props.users.map((user) => (
|
||||||
<Link to="/admin-view-user" key={user.id} state={user.userName}>
|
<Link to="/admin-view-user" key={user.userId} state={user.username}>
|
||||||
<li className="pt-5" key={user.id}>
|
<li className="pt-5" key={user.userId}>
|
||||||
{user.userName}
|
{user.username}
|
||||||
</li>
|
</li>
|
||||||
</Link>
|
</Link>
|
||||||
))}
|
))}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import BasicWindow from "../../Components/BasicWindow";
|
import BasicWindow from "../../Components/BasicWindow";
|
||||||
import Button from "../../Components/Button";
|
import Button from "../../Components/Button";
|
||||||
import NewTimeReport from "../../Components/TimeReport";
|
import NewTimeReport from "../../Components/TimeReport";
|
||||||
import BackButton from "../../Components/BackButton";
|
import { Link } from "react-router-dom";
|
||||||
|
|
||||||
function UserNewTimeReportPage(): JSX.Element {
|
function UserNewTimeReportPage(): JSX.Element {
|
||||||
const content = (
|
const content = (
|
||||||
|
|
Loading…
Reference in a new issue