From c79785e09b4af0ca453663c07359e10b1ef03521 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 16 Nov 2020 19:05:41 +0100 Subject: subscription form seemingly working --- .../frontend/app/views/viewer/forms/subscription.form.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'animism-align/frontend/app/views/viewer/forms/subscription.form.js') diff --git a/animism-align/frontend/app/views/viewer/forms/subscription.form.js b/animism-align/frontend/app/views/viewer/forms/subscription.form.js index 9c84614..956941b 100644 --- a/animism-align/frontend/app/views/viewer/forms/subscription.form.js +++ b/animism-align/frontend/app/views/viewer/forms/subscription.form.js @@ -12,6 +12,7 @@ const initialState = { email: "", agreed: false, subscribed: false, + success: false, loading: false, } @@ -47,13 +48,16 @@ export default class SubscriptionForm extends Component { if (ENV_PRODUCTION) { this.setState({ loading: true }) subscriptionActions.subscribe(this.state.email) - .then(() => { - this.setState({ loading: false, subscribed: true }) + .then(res => { + this.setState({ loading: false, subscribed: true, success: res.ok }) + }) + .catch(err => { + this.setState({ loading: false, subscribed: true, success: false }) }) } else { this.setState({ loading: true }) setTimeout(() => { - this.setState({ loading: false, subscribed: true }) + this.setState({ loading: false, subscribed: true, success: true }) }, 1000) } } @@ -107,7 +111,11 @@ export default class SubscriptionForm extends Component {
- Thanks! You will receive an email soon confirming your subscription. + {this.state.success ? ( + "Thanks! You will receive an email soon confirming your subscription." + ) : ( + "Sorry, there was a problem adding your subscription." + )}
-- cgit v1.2.3-70-g09d2