diff --git a/frontend/src/LoginPage/LoginPage.jsx b/frontend/src/LoginPage/LoginPage.jsx index 0c59426a4e..a1bf8638cd 100644 --- a/frontend/src/LoginPage/LoginPage.jsx +++ b/frontend/src/LoginPage/LoginPage.jsx @@ -10,6 +10,10 @@ class LoginPage extends React.Component { if (authenticationService.currentUserValue) { this.props.history.push('/'); } + + this.state = { + isLoading: false + }; } handleChange = (event) => { @@ -19,20 +23,26 @@ class LoginPage extends React.Component { authUser = (e) => { e.preventDefault(); + this.setState({ isLoading: true }); + const { email, password } = this.state; authenticationService.login(email, password).then( () => { const { from } = this.props.location.state || { from: { pathname: '/' } }; this.props.history.push(from); + this.setState({ isLoading: false }); }, () => { toast.error('Invalid username or password', { hideProgressBar: true, position: 'top-center' }); + this.setState({ isLoading: false }); } ); }; render() { + const { isLoading } = this.state; + return (