diff options
| -rw-r--r-- | animism-align/frontend/app/views/viewer/forms/subscription.actions.js | 8 | ||||
| -rw-r--r-- | animism-align/frontend/app/views/viewer/forms/subscription.form.js | 16 |
2 files changed, 14 insertions, 10 deletions
diff --git a/animism-align/frontend/app/views/viewer/forms/subscription.actions.js b/animism-align/frontend/app/views/viewer/forms/subscription.actions.js index bf7a30e..f1257b2 100644 --- a/animism-align/frontend/app/views/viewer/forms/subscription.actions.js +++ b/animism-align/frontend/app/views/viewer/forms/subscription.actions.js @@ -10,10 +10,6 @@ export const subscribe = email => { body: data, }) .then(res => res.json()) - .then(res => { - return res - }) - .catch(err => { - return err - }) + .then(res => res) + .catch(err => err) } 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 { <Loader /> </div> <div className="subscription-thanks"> - 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." + )} <br /> <button className="subscription-reset" onClick={this.handleReset}>OK</button> </div> |
