2024-03-13 17:56:04 +01:00
|
|
|
import { useState } from "react";
|
2024-03-14 18:32:56 +01:00
|
|
|
import { NewUser } from "../Types/Users";
|
2024-03-14 11:23:57 +01:00
|
|
|
import { api } from "../API/API";
|
2024-03-15 14:16:11 +01:00
|
|
|
import Logo from "../assets/Logo.svg";
|
2024-03-13 17:56:04 +01:00
|
|
|
|
2024-03-14 11:23:57 +01:00
|
|
|
export default function Register(): JSX.Element {
|
|
|
|
const [username, setUsername] = useState("");
|
|
|
|
const [password, setPassword] = useState("");
|
2024-03-13 17:56:04 +01:00
|
|
|
|
2024-03-14 11:23:57 +01:00
|
|
|
const handleRegister = async (): Promise<void> => {
|
|
|
|
const newUser: NewUser = { userName: username, password };
|
2024-03-14 18:32:56 +01:00
|
|
|
await api.registerUser(newUser); // TODO: Handle errors
|
2024-03-13 17:56:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
2024-03-15 14:16:11 +01:00
|
|
|
<div className="flex flex-col h-screen w-screen items-center justify-center">
|
|
|
|
<div className="border-4 border-black bg-white flex flex-col items-center justify-center h-fit w-fit rounded-3xl content-center pl-20 pr-20">
|
2024-03-13 17:56:04 +01:00
|
|
|
<form
|
2024-03-15 14:16:11 +01:00
|
|
|
className="bg-white rounded px-8 pt-6 pb-8 mb-4 items-center justify-center flex flex-col w-fit h-fit"
|
2024-03-13 17:56:04 +01:00
|
|
|
onSubmit={(e) => {
|
|
|
|
e.preventDefault();
|
2024-03-14 11:23:57 +01:00
|
|
|
void handleRegister();
|
2024-03-13 17:56:04 +01:00
|
|
|
}}
|
|
|
|
>
|
2024-03-15 14:16:11 +01:00
|
|
|
<img
|
|
|
|
src={Logo}
|
|
|
|
className="logo w-[7vw] mb-10 mt-10"
|
|
|
|
alt="TTIME Logo"
|
|
|
|
/>
|
|
|
|
<h3 className="pb-2 text-center">Register new user</h3>
|
2024-03-13 17:56:04 +01:00
|
|
|
<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}
|
2024-03-14 11:23:57 +01:00
|
|
|
onChange={(e) => {
|
|
|
|
setUsername(e.target.value);
|
|
|
|
}}
|
2024-03-13 17:56:04 +01:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="mb-6">
|
|
|
|
<label
|
|
|
|
className="block text-gray-700 text-sm font-bold mb-2"
|
|
|
|
htmlFor="password"
|
|
|
|
>
|
|
|
|
Password
|
|
|
|
</label>
|
|
|
|
<input
|
2024-03-14 11:23:57 +01:00
|
|
|
className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 mb-3 leading-tight focus:outline-none focus:shadow-outline"
|
2024-03-13 17:56:04 +01:00
|
|
|
id="password"
|
|
|
|
type="password"
|
|
|
|
placeholder="Choose your password"
|
|
|
|
value={password}
|
2024-03-14 11:23:57 +01:00
|
|
|
onChange={(e) => {
|
|
|
|
setPassword(e.target.value);
|
|
|
|
}}
|
2024-03-13 17:56:04 +01:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="flex items-center justify-between">
|
|
|
|
<button
|
2024-03-15 14:30:45 +01:00
|
|
|
className="inline-block py-1 px-8 font-bold bg-orange-500 text-white border-2 border-black rounded-full cursor-pointer mt-5 mb-5 transition-colors duration-10 hover:bg-orange-600 hover:text-gray-300 font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-size: 4vh;"
|
2024-03-13 17:56:04 +01:00
|
|
|
type="submit"
|
|
|
|
>
|
|
|
|
Register
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
<p className="text-center text-gray-500 text-xs"></p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|