layout; routing; login
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import {useContext, useState} from 'react'
|
||||
import {Link} from 'react-router-dom'
|
||||
import {UserCtx, UserCtxT} from '../context/UserContext';
|
||||
import './Register.css';
|
||||
|
||||
|
||||
const Register = () => {
|
||||
@ -9,7 +10,8 @@ const Register = () => {
|
||||
const [successMsg, setSuccessMsg] = useState("false");
|
||||
const [formData, setFormData] = useState({
|
||||
email:'',
|
||||
password:''
|
||||
password:'',
|
||||
password2:''
|
||||
});
|
||||
|
||||
const onChangeInput = (e: React.FormEvent<HTMLInputElement> ) => {
|
||||
@ -29,6 +31,14 @@ const Register = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
if(formData.password !== formData.password2)
|
||||
{
|
||||
setSuccessMsg("false");
|
||||
setErrMsg('Bitte 2mal das gleiche Passwort eingeben!');
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
const data = await registerUser(formData);
|
||||
if(data.success){
|
||||
setSuccessMsg('Erfolgreich Registriert!');
|
||||
@ -42,13 +52,21 @@ const Register = () => {
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h2>Sign Up</h2>
|
||||
<div className='Register'>
|
||||
<h2>Register</h2>
|
||||
<form onSubmit={submitForm}>
|
||||
<label htmlFor="email">Email:</label>
|
||||
<input type="email" name="email" onChange={onChangeInput} placeholder="Deine email" id="email" value={formData.email} required />
|
||||
<label htmlFor="password">Password:</label>
|
||||
<input type="password" name="password" onChange={onChangeInput} placeholder="New password" id="password" value={formData.password} required />
|
||||
<div className='neben'>
|
||||
<label htmlFor="email">Email: </label>
|
||||
<input type="email" name="email" onChange={onChangeInput} placeholder="Deine email" id="email" value={formData.email} required />
|
||||
</div>
|
||||
<div className='neben'>
|
||||
<label htmlFor="password">Passwort: </label>
|
||||
<input type="password" name="password" onChange={onChangeInput} placeholder="New password" id="password" value={formData.password} required />
|
||||
</div>
|
||||
<div className='neben'>
|
||||
<label htmlFor="password2">Passwort wiederholen: </label>
|
||||
<input type="password" name="password2" onChange={onChangeInput} placeholder="New password" id="password2" value={formData.password2} required />
|
||||
</div>
|
||||
{successMsg !== "false" && <div className="success-msg">{successMsg}</div>}
|
||||
{errMsg !== "false" && <div className="err-msg">{errMsg}</div>}
|
||||
<button type="submit" disabled={wait}>Register</button>
|
||||
|
||||
Reference in New Issue
Block a user