Show loading state while submitting password reset form (#2487)

This commit is contained in:
Olaleye Blessing 2022-03-11 04:01:47 +01:00 committed by GitHub
parent 498ddcd836
commit 18ef3273d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,6 +31,9 @@ class ResetPassword extends React.Component {
password_confirmation: '',
});
} else {
this.setState({
isLoading: true,
});
fetch(`${config.apiUrl}/reset_password`, {
method: 'POST',
headers: {
@ -41,13 +44,22 @@ class ResetPassword extends React.Component {
.then((res) => res.json())
.then((res) => {
if (res.error) {
// update loading state here since user will still be on the page
this.setState({
isLoading: false,
});
toast.error(res.message);
} else {
toast.success(res.message);
this.props.history.push('/login');
}
})
.catch(console.log);
.catch((err) => {
this.setState({
isLoading: false,
});
console.log(err);
});
}
};
render() {