This commit is contained in:
Victor
2024-03-27 10:51:41 +01:00
commit 1b61871097
38 changed files with 9828 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
import React, { useState } from "react";
import { useAuth } from "../../hooks";
export const Register = () => {
const { register } = useAuth();
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
const [confirmation, setConfirmation] = useState("");
const [error, setError] = useState();
const onSubmit = async (e) => {
e.preventDefault();
const response = await register(username, password, confirmation);
if (response && !response.success) {
setError(response.error);
}
};
return (
<div>
<h1>Register page</h1>
{error && <p className="text-red-500">{error}</p>}
<form onSubmit={onSubmit}>
<input
type="text"
value={username}
placeholder="username"
onChange={(e) => setUsername(e.target.value)}
/>
<input
type="password"
value={password}
placeholder="password"
onChange={(e) => setPassword(e.target.value)}
/>
<input
type="password"
value={confirmation}
placeholder="confirmation"
onChange={(e) => setConfirmation(e.target.value)}
/>
<button type="submit">submit</button>
</form>
</div>
);
};