Merge branch 'frontend' into gruppPP
This commit is contained in:
commit
516784c6bb
12 changed files with 280 additions and 111 deletions
|
|
@ -6,12 +6,23 @@ import Button from "./Button";
|
|||
import InputField from "./InputField";
|
||||
|
||||
export default function Register(): JSX.Element {
|
||||
const [username, setUsername] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
const [username, setUsername] = useState<string>();
|
||||
const [password, setPassword] = useState<string>();
|
||||
const [errMessage, setErrMessage] = useState<string>();
|
||||
|
||||
const nav = useNavigate();
|
||||
|
||||
const handleRegister = async (): Promise<void> => {
|
||||
const newUser: NewUser = { username: username, password };
|
||||
await api.registerUser(newUser); // TODO: Handle errors
|
||||
const newUser: NewUser = {
|
||||
username: username ?? "",
|
||||
password: password ?? "",
|
||||
};
|
||||
const response = await api.registerUser(newUser);
|
||||
if (response.success) {
|
||||
nav("/"); // Instantly navigate to the login page
|
||||
} else {
|
||||
setErrMessage(response.message ?? "Unknown error");
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue