diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-11-16 19:05:41 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-11-16 19:05:41 +0100 |
| commit | c79785e09b4af0ca453663c07359e10b1ef03521 (patch) | |
| tree | 7626638f0b29ee1ed4adb2474584bc60ef3a08b5 /animism-align/frontend/app/views | |
| parent | 119a5fc20a550dca617d2bdb83c059a9acc389e8 (diff) | |
subscription form seemingly working
Diffstat (limited to 'animism-align/frontend/app/views')
| -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> |
