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

View File

@ -16,7 +16,10 @@ import {
import { TurniereNavigation } from '../js/components/Navigation'; import { TurniereNavigation } from '../js/components/Navigation';
import { Footer } from '../js/components/Footer'; import { Footer } from '../js/components/Footer';
import { register } from '../js/api'; import { register } from '../js/api';
import { verifyCredentials } from '../js/api'; import {
verifyCredentials,
clearErrors
} from '../js/api';
import '../static/everypage.css'; import '../static/everypage.css';
@ -43,7 +46,13 @@ export default class RegisterPage extends React.Component {
} }
} }
function Register() { class Register extends React.Component {
componentDidMount() {
clearErrors();
}
render() {
return ( return (
<Container className="py-5"> <Container className="py-5">
<Card className="shadow"> <Card className="shadow">
@ -58,6 +67,7 @@ function Register() {
</Container> </Container>
); );
} }
}
class RegisterErrorList extends React.Component { class RegisterErrorList extends React.Component {
render() { render() {