From 92cf36d1786a783445884aaee80211ab8cc24526 Mon Sep 17 00:00:00 2001 From: pavel Hamawand Date: Fri, 15 Mar 2024 01:42:43 +0100 Subject: [PATCH 001/105] increased responsiveness - outer div --- frontend/src/Pages/LoginPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/Pages/LoginPage.tsx b/frontend/src/Pages/LoginPage.tsx index 7dabfbe..6ccf8fa 100644 --- a/frontend/src/Pages/LoginPage.tsx +++ b/frontend/src/Pages/LoginPage.tsx @@ -30,7 +30,7 @@ function LoginPage(): JSX.Element { <>
Date: Fri, 15 Mar 2024 02:03:22 +0100 Subject: [PATCH 002/105] links to all projects --- frontend/src/Pages/YourProjectsPage.tsx | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/frontend/src/Pages/YourProjectsPage.tsx b/frontend/src/Pages/YourProjectsPage.tsx index d6f5743..7ec147d 100644 --- a/frontend/src/Pages/YourProjectsPage.tsx +++ b/frontend/src/Pages/YourProjectsPage.tsx @@ -11,15 +11,21 @@ function YourProjectsPage(): JSX.Element { ProjectNameExample -

- ProjectNameExample2 -

-

- ProjectNameExample3 -

-

- ProjectNameExample4 -

+ +

+ ProjectNameExample2 +

+ + +

+ ProjectNameExample3 +

+ + +

+ ProjectNameExample4 +

+
); From 2ad7146588bc6a0ab3b45c0416fd45b54a810538 Mon Sep 17 00:00:00 2001 From: Peter KW Date: Fri, 15 Mar 2024 02:28:28 +0100 Subject: [PATCH 003/105] Added some functionality to login page. Checks username + password and compares with "fake" users to determine which page to get --- frontend/src/Pages/LoginPage.tsx | 68 +++++++++++++++++++++++++------- 1 file changed, 54 insertions(+), 14 deletions(-) diff --git a/frontend/src/Pages/LoginPage.tsx b/frontend/src/Pages/LoginPage.tsx index 6ccf8fa..9b4290d 100644 --- a/frontend/src/Pages/LoginPage.tsx +++ b/frontend/src/Pages/LoginPage.tsx @@ -1,8 +1,9 @@ import Button from "../Components/Button"; import Logo from "/src/assets/Logo.svg"; import "./LoginPage.css"; -import { useEffect } from "react"; -import { Link } from "react-router-dom"; +import { FormEvent, useEffect, useState } from "react"; +import { NewUser } from "../Types/Users"; +import { useNavigate } from "react-router-dom"; const PreloadBackgroundAnimation = (): JSX.Element => { useEffect(() => { @@ -26,6 +27,39 @@ const PreloadBackgroundAnimation = (): JSX.Element => { }; function LoginPage(): JSX.Element { + //Example users for testing without backend, remove when using backend + const admin: NewUser = { + name: "admin", + password: "123", + }; + const pmanager: NewUser = { + name: "pmanager", + password: "123", + }; + const user: NewUser = { + name: "user", + password: "123", + }; + + const navigate = useNavigate(); + + /* On submit (enter or button click) check if username and password match any user + and if so, redirect to correct page */ + function handleSubmit(event: FormEvent): void { + event.preventDefault(); + //TODO: Compare with db instead when finished + if (username === admin.name && password === admin.password) { + navigate("/admin-menu"); + } else if (username === pmanager.name && password === pmanager.password) { + navigate("/PM-project-page"); + } else if (username === user.name && password === user.password) { + navigate("/your-projects"); + } + } + + const [username, setUsername] = useState(""); + const [password, setPassword] = useState(""); + return ( <> @@ -51,24 +85,30 @@ function LoginPage(): JSX.Element { {" "} Please log in to continue{" "} - - - +
+ { + setUsername(e.target.value); + }} + /> + { + setPassword(e.target.value); + }} + />
+ ); +} + +export default BackButton; From 6789cc97cea5fac14116639143fb8ff0a65228f2 Mon Sep 17 00:00:00 2001 From: Peter KW Date: Fri, 15 Mar 2024 14:57:49 +0100 Subject: [PATCH 009/105] Added back button to page --- frontend/src/Pages/AdminPages/AdminManageUsers.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/frontend/src/Pages/AdminPages/AdminManageUsers.tsx b/frontend/src/Pages/AdminPages/AdminManageUsers.tsx index b25b120..610e8d2 100644 --- a/frontend/src/Pages/AdminPages/AdminManageUsers.tsx +++ b/frontend/src/Pages/AdminPages/AdminManageUsers.tsx @@ -1,5 +1,6 @@ import BasicWindow from "../../Components/BasicWindow"; import Button from "../../Components/Button"; +import BackButton from "../../Components/BackButton"; function AdminManageUsers(): JSX.Element { const content = <>; @@ -12,12 +13,7 @@ function AdminManageUsers(): JSX.Element { return; }} /> - {isOpen && ( From 164ff781b3e4799f977872bbd1455644d83cd7c4 Mon Sep 17 00:00:00 2001 From: Davenludd Date: Mon, 18 Mar 2024 10:43:52 +0100 Subject: [PATCH 105/105] Add useEffect hook to handle authority navigation and log response in YourProjectsPage --- frontend/src/Pages/App.tsx | 19 +++++++++++-------- frontend/src/Pages/YourProjectsPage.tsx | 1 + 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/frontend/src/Pages/App.tsx b/frontend/src/Pages/App.tsx index 7ded3b6..4263815 100644 --- a/frontend/src/Pages/App.tsx +++ b/frontend/src/Pages/App.tsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useState, useEffect } from "react"; import LoginPage from "./LoginPage"; import { useNavigate } from "react-router-dom"; @@ -6,13 +6,16 @@ import { useNavigate } from "react-router-dom"; function App(): JSX.Element { const navigate = useNavigate(); const [authority, setAuthority] = useState(0); - if (authority === 1) { - navigate("/admin"); - } else if (authority === 2) { - navigate("/pm"); - } else if (authority === 3) { - navigate("/user"); - } + + useEffect(() => { + if (authority === 1) { + navigate("/admin"); + } else if (authority === 2) { + navigate("/pm"); + } else if (authority === 3) { + navigate("/user"); + } + }, [authority, navigate]); return ; } diff --git a/frontend/src/Pages/YourProjectsPage.tsx b/frontend/src/Pages/YourProjectsPage.tsx index 4e43bb6..30912a6 100644 --- a/frontend/src/Pages/YourProjectsPage.tsx +++ b/frontend/src/Pages/YourProjectsPage.tsx @@ -11,6 +11,7 @@ function UserProjectPage(): JSX.Element { const username = localStorage.getItem("username") ?? ""; // replace with actual username const token = localStorage.getItem("accessToken") ?? ""; // replace with actual token const response = await api.getUserProjects(username, token); + console.log(response); if (response.success) { setProjects(response.data ?? []); } else {