diff --git a/browser/main/modals/PreferencesModal/InfoTab.js b/browser/main/modals/PreferencesModal/InfoTab.js index d4b2a408..88cc935b 100644 --- a/browser/main/modals/PreferencesModal/InfoTab.js +++ b/browser/main/modals/PreferencesModal/InfoTab.js @@ -16,7 +16,10 @@ class InfoTab extends React.Component { super(props) this.state = { - config: this.props.config + config: this.props.config, + subscriptionFormStatus: 'idle', + subscriptionFormErrorMessage: null, + subscriptionFormEmail: '' } } @@ -31,6 +34,48 @@ class InfoTab extends React.Component { this.setState({ config: newConfig }) } + handleSubscriptionFormSubmit(e) { + e.preventDefault() + this.setState({ + subscriptionFormStatus: 'sending', + subscriptionFormErrorMessage: null + }) + + fetch( + 'https://boostmails.boostio.co/api/public/lists/5f434dccd05f3160b41c0d49/subscriptions', + { + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json' + }, + method: 'POST', + body: JSON.stringify({ email: this.state.subscriptionFormEmail }) + } + ) + .then(response => { + if (response.status >= 400) { + return response.text().then(text => { + throw new Error(text) + }) + } + this.setState({ + subscriptionFormStatus: 'done' + }) + }) + .catch(error => { + this.setState({ + subscriptionFormStatus: 'idle', + subscriptionFormErrorMessage: error.message + }) + }) + } + + handleSubscriptionFormEmailChange(e) { + this.setState({ + subscriptionFormEmail: e.target.value + }) + } + handleSaveButtonClick(e) { const newConfig = { amaEnabled: this.state.config.amaEnabled @@ -134,6 +179,40 @@ class InfoTab extends React.Component {
+
Subscribe Update Notes
+ {this.state.subscriptionFormStatus === 'done' ? ( +
+
+ Thanks for the subscription! +
+
+ ) : ( +
+ {this.state.subscriptionFormErrorMessage != null && ( +
+ {this.state.subscriptionFormErrorMessage} +
+ )} +
this.handleSubscriptionFormSubmit(e)}> + this.handleSubscriptionFormEmailChange(e)} + disabled={this.state.subscriptionFormStatus === 'sending'} + /> + +
+
+ )} +
+
{i18n.__('About')}
diff --git a/browser/main/modals/PreferencesModal/InfoTab.styl b/browser/main/modals/PreferencesModal/InfoTab.styl index 4701d809..faaf621f 100644 --- a/browser/main/modals/PreferencesModal/InfoTab.styl +++ b/browser/main/modals/PreferencesModal/InfoTab.styl @@ -33,6 +33,35 @@ .separate-line margin 40px 0 +.subscription-email-input + height 35px + vertical-align middle + width 200px + font-size $tab--button-font-size + border solid 1px $border-color + border-radius 2px + padding 0 5px + margin-right 5px + outline none + &:disabled + background-color $ui-input--disabled-backgroundColor + +.subscription-submit-button + margin-top 10px + height 35px + border-radius 2px + border none + background-color alpha(#1EC38B, 90%) + padding-left 20px + padding-right 20px + text-decoration none + color white + font-weight 600 + font-size 16px + &:hover + background-color #1EC38B + transition 0.2s + .policy-submit margin-top 10px height 35px