Make the login and register components clear errors as soon as they are mounted
This commit is contained in:
parent
5a34b415f2
commit
f3c429692c
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -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,20 +46,27 @@ export default class RegisterPage extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Register() {
|
class Register extends React.Component {
|
||||||
return (
|
|
||||||
<Container className="py-5">
|
componentDidMount() {
|
||||||
<Card className="shadow">
|
clearErrors();
|
||||||
<CardBody>
|
}
|
||||||
<h1 className="custom-font">Account anlegen</h1>
|
|
||||||
<RegisterForm/>
|
render() {
|
||||||
<div className="mt-3">
|
return (
|
||||||
<a href="/login" className="mr-3">Ich habe bereits einen Account!</a>
|
<Container className="py-5">
|
||||||
</div>
|
<Card className="shadow">
|
||||||
</CardBody>
|
<CardBody>
|
||||||
</Card>
|
<h1 className="custom-font">Account anlegen</h1>
|
||||||
</Container>
|
<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 {
|
class RegisterErrorList extends React.Component {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue