Make the login and register components clear errors as soon as they are mounted

This commit is contained in:
JP1998 2019-04-11 14:13:43 +02:00
parent 5a34b415f2
commit f3c429692c
2 changed files with 33 additions and 16 deletions

View File

@ -3,7 +3,10 @@ import React from 'react';
import {connect} from 'react-redux';
import Router from 'next/router';
import {login} from '../api';
import {
login,
clearErrors
} from '../api';
export function Login(props) {
return (
@ -84,6 +87,10 @@ class LoginForm extends React.Component {
};
}
componentDidMount() {
clearErrors();
}
tryLogin(event) {
event.preventDefault();
login(this.state.email, this.state.password);

View File

@ -16,7 +16,10 @@ import {
import { TurniereNavigation } from '../js/components/Navigation';
import { Footer } from '../js/components/Footer';
import { register } from '../js/api';
import { verifyCredentials } from '../js/api';
import {
verifyCredentials,
clearErrors
} from '../js/api';
import '../static/everypage.css';
@ -43,20 +46,27 @@ export default class RegisterPage extends React.Component {
}
}
function Register() {
return (
<Container className="py-5">
<Card className="shadow">
<CardBody>
<h1 className="custom-font">Account anlegen</h1>
<RegisterForm/>
<div className="mt-3">
<a href="/login" className="mr-3">Ich habe bereits einen Account!</a>
</div>
</CardBody>
</Card>
</Container>
);
class Register extends React.Component {
componentDidMount() {
clearErrors();
}
render() {
return (
<Container className="py-5">
<Card className="shadow">
<CardBody>
<h1 className="custom-font">Account anlegen</h1>
<RegisterForm/>
<div className="mt-3">
<a href="/login" className="mr-3">Ich habe bereits einen Account!</a>
</div>
</CardBody>
</Card>
</Container>
);
}
}
class RegisterErrorList extends React.Component {