Compare commits
No commits in common. "e1bf25148e45e7b5f5ffe7b937e3e8e552c64862" and "b5c29872818184fa95e2bd029dc83e0b35fb7898" have entirely different histories.
e1bf25148e
...
b5c2987281
4 changed files with 2 additions and 98 deletions
|
@ -1,82 +0,0 @@
|
||||||
import { useState } from "react";
|
|
||||||
import { NewUser, User } from "../Types/Users";
|
|
||||||
|
|
||||||
export default function Register() {
|
|
||||||
const [username, setUsername] = useState('')
|
|
||||||
const [password, setPassword] = useState('')
|
|
||||||
const [error, setError] = useState('')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const handleRegister = async () => {
|
|
||||||
try {
|
|
||||||
const newUser: NewUser = { username, password };
|
|
||||||
const registeredUser: User = await api.registerUser(newUser);
|
|
||||||
console.log("User registered:", registeredUser);
|
|
||||||
// Optionally, you can navigate to another page or show a success message here
|
|
||||||
} catch (error) {
|
|
||||||
setError("Registration failed. Please try again."); // Handle error appropriately
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<div className="w-full max-w-xs">
|
|
||||||
<form
|
|
||||||
className="bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4"
|
|
||||||
onSubmit={(e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
handleRegister();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<h3 className="pb-2">Register new user</h3>
|
|
||||||
<div className="mb-4">
|
|
||||||
<label
|
|
||||||
className="block text-gray-700 text-sm font-bold mb-2"
|
|
||||||
htmlFor="username"
|
|
||||||
>
|
|
||||||
Username
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
|
|
||||||
id="username"
|
|
||||||
type="text"
|
|
||||||
placeholder="Username"
|
|
||||||
value={username}
|
|
||||||
onChange={(e) => setUsername(e.target.value)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="mb-6">
|
|
||||||
<label
|
|
||||||
className="block text-gray-700 text-sm font-bold mb-2"
|
|
||||||
htmlFor="password"
|
|
||||||
>
|
|
||||||
Password
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
className="shadow appearance-none border border-red-500 rounded w-full py-2 px-3 text-gray-700 mb-3 leading-tight focus:outline-none focus:shadow-outline"
|
|
||||||
id="password"
|
|
||||||
type="password"
|
|
||||||
placeholder="Choose your password"
|
|
||||||
value={password}
|
|
||||||
onChange={(e) => setPassword(e.target.value)}
|
|
||||||
/>
|
|
||||||
<p className="text-red-500 text-xs italic">
|
|
||||||
Please choose a password.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center justify-between">
|
|
||||||
<button
|
|
||||||
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"
|
|
||||||
type="submit"
|
|
||||||
>
|
|
||||||
Register
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
{error && <p className="text-red-500 text-xs italic">{error}</p>}
|
|
||||||
</form>
|
|
||||||
<p className="text-center text-gray-500 text-xs"></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -3,7 +3,6 @@ import Logo from "/src/assets/TTIMElogo.png";
|
||||||
import "./LoginPage.css";
|
import "./LoginPage.css";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import Register from "../Components/Register";
|
|
||||||
|
|
||||||
const PreloadBackgroundAnimation = (): JSX.Element => {
|
const PreloadBackgroundAnimation = (): JSX.Element => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -70,14 +69,6 @@ function LoginPage(): JSX.Element {
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Link>
|
</Link>
|
||||||
<Link to="/register">
|
|
||||||
<Button
|
|
||||||
text="Register new user"
|
|
||||||
onClick={(): void => {
|
|
||||||
return;
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Link>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// This is how the API responds
|
// This is how the API responds
|
||||||
export interface User {
|
export interface User {
|
||||||
id: number;
|
id: number;
|
||||||
userName: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to create a new user
|
// Used to create a new user
|
||||||
export interface NewUser {
|
export interface NewUser {
|
||||||
userName: string;
|
name: string;
|
||||||
password: string;
|
password: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import { createBrowserRouter, RouterProvider } from "react-router-dom";
|
||||||
import LoginPage from "./Pages/LoginPage.tsx";
|
import LoginPage from "./Pages/LoginPage.tsx";
|
||||||
import YourProjectsPage from "./Pages/YourProjectsPage.tsx";
|
import YourProjectsPage from "./Pages/YourProjectsPage.tsx";
|
||||||
import UserProjectPage from "./Pages/UserPages/UserProjectPage.tsx";
|
import UserProjectPage from "./Pages/UserPages/UserProjectPage.tsx";
|
||||||
import Register from "./Components/Register.tsx";
|
|
||||||
|
|
||||||
// This is where the routes are mounted
|
// This is where the routes are mounted
|
||||||
const router = createBrowserRouter([
|
const router = createBrowserRouter([
|
||||||
|
@ -21,10 +20,6 @@ const router = createBrowserRouter([
|
||||||
path: "/project",
|
path: "/project",
|
||||||
element: <UserProjectPage />,
|
element: <UserProjectPage />,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: "/register",
|
|
||||||
element: <Register />,
|
|
||||||
},
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Semi-hacky way to get the root element
|
// Semi-hacky way to get the root element
|
||||||
|
|
Loading…
Reference in a new issue