error msg is back
This commit is contained in:
1 parent
12f00eb639
commit
c99f6fd2b6
3 files changed
+20
-6
No files matched your search
@@ -7,17 +7,17 @@ const Login = ({ success }) => {
|
||||
const [email, setEmail] = useState('')
|
||||
const [password, setPassword] = useState('');
|
||||
const [confirmPassword, setConfirmPassword] = useState('');
|
||||
const [error, setError] = useState('');
|
||||
|
||||
async function postLogin() {
|
||||
const [error, user] = await actions.postLogin(email, password);
|
||||
console.log(error, user);
|
||||
if (error) return console.warn(error);
|
||||
if (error) return setError(error);
|
||||
success(user);
|
||||
}
|
||||
|
||||
async function postRegister() {
|
||||
const [error, user] = await actions.postRegister(email, password);
|
||||
if (error) return console.warn(error);
|
||||
if (error) return setError(error);
|
||||
success(user);
|
||||
}
|
||||
|
||||
@@ -27,8 +27,13 @@ const Login = ({ success }) => {
|
||||
if (mode === 'register') return postRegister();
|
||||
}
|
||||
|
||||
const errorEl = error
|
||||
? <div class='alt-text'>{error}</div>
|
||||
: null;
|
||||
|
||||
if (mode === 'register') return (
|
||||
<div class="login">
|
||||
{errorEl}
|
||||
<form action="">
|
||||
<div class="item">
|
||||
<label for="email">email</label>
|
||||
@@ -53,6 +58,7 @@ const Login = ({ success }) => {
|
||||
|
||||
return (
|
||||
<div class="login">
|
||||
{errorEl}
|
||||
<form action="">
|
||||
<div class="item">
|
||||
<label for="email">email</label>
|
||||
@@ -66,7 +72,6 @@ const Login = ({ success }) => {
|
||||
<input type="submit" value="login" onClick={handleSubmit} />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<button onClick={() => setMode('register')} >Click to register</button>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user