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,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">
|
||||||
|
|
@ -57,6 +66,7 @@ function Register() {
|
||||||
</Card>
|
</Card>
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class RegisterErrorList extends React.Component {
|
class RegisterErrorList extends React.Component {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue