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 {
|
||||
//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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<void> => {
|
||||
const newUser: NewUser = { userName: username, password };
|
||||
const newUser: NewUser = { username: username, password };
|
||||
await api.registerUser(newUser); // TODO: Handle errors
|
||||
};
|
||||
|
||||
|
|
|
@ -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<string>("projectName"); // TODO: Get from backend
|
||||
const [week, setWeek] = useState<number>(NaN);
|
||||
const [development, setDevelopment] = useState<number>(NaN);
|
||||
const [meeting, setMeeting] = useState<number>(NaN);
|
||||
const [administration, setAdministration] = useState<number>(NaN);
|
||||
const [ownwork, setOwnWork] = useState<number>(NaN);
|
||||
const [studies, setStudies] = useState<number>(NaN);
|
||||
const [testing, setTesting] = useState<number>(NaN);
|
||||
|
||||
const handleNewTimeReport = async (): Promise<void> => {
|
||||
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 (
|
||||
<>
|
||||
<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
|
||||
onSubmit={(e) => {
|
||||
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;
|
||||
|
|
|
@ -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 {
|
|||
<div>
|
||||
<ul className="font-bold underline text-[30px] cursor-pointer padding">
|
||||
{props.users.map((user) => (
|
||||
<Link to="/admin-view-user" key={user.id} state={user.userName}>
|
||||
<li className="pt-5" key={user.id}>
|
||||
{user.userName}
|
||||
<Link to="/admin-view-user" key={user.userId} state={user.username}>
|
||||
<li className="pt-5" key={user.userId}>
|
||||
{user.username}
|
||||
</li>
|
||||
</Link>
|
||||
))}
|
||||
|
|
|
@ -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 = (
|
||||
|
|
Loading…
Reference in a new issue