Bachelorthesis_Code/frontend/src/components/pages/Register.js

58 lines
1.3 KiB
JavaScript

import React from "react";
import { useState } from "react/cjs/react.development";
import "../../App.css";
import Footer from "../../Footer";
import InputField from "../InputField";
import SubmitField from "../SubmitField";
export default function Login() {
const [username, setUsername] = useState('')
const [password, setPassword] = useState('')
const onSubmitClick = (e) => {
e.preventDefault();
let opts = {
username: username,
password: password,
};
console.log(opts);
fetch("/api/register", {
method: "post",
body: JSON.stringify(opts),
})
};
const handleUsernameChange = (e) => {
setUsername(e.target.value);
};
const handlePasswordChange = (e) => {
setPassword(e.target.value);
};
return (
<>
<div className="sitePage">
<h1>Registrierung</h1>
<form>
<InputField
LabelName="Benutzername / Kennung"
InputType="text"
onChange={handleUsernameChange}
InputName="username"
/>
<InputField
LabelName="Passwort"
InputType="password"
onChange={handlePasswordChange}
InputName="password"
/>
<br />
<SubmitField onClick={onSubmitClick} LabelName="Einloggen" />
</form>
</div>
<Footer />
</>
);
}