mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-12 17:26:17 +00:00
Add email subscription form
This commit is contained in:
@@ -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 {
|
||||
|
||||
<hr />
|
||||
|
||||
<div styleName='group-header--sub'>Subscribe Update Notes</div>
|
||||
{this.state.subscriptionFormStatus === 'done' ? (
|
||||
<div>
|
||||
<blockquote color={{ color: 'green' }}>
|
||||
Thanks for the subscription!
|
||||
</blockquote>
|
||||
</div>
|
||||
) : (
|
||||
<div>
|
||||
{this.state.subscriptionFormErrorMessage != null && (
|
||||
<blockquote style={{ color: 'red' }}>
|
||||
{this.state.subscriptionFormErrorMessage}
|
||||
</blockquote>
|
||||
)}
|
||||
<form onSubmit={e => this.handleSubscriptionFormSubmit(e)}>
|
||||
<input
|
||||
styleName='subscription-email-input'
|
||||
placeholder='E-mail'
|
||||
type='email'
|
||||
onChange={e => this.handleSubscriptionFormEmailChange(e)}
|
||||
disabled={this.state.subscriptionFormStatus === 'sending'}
|
||||
/>
|
||||
<button
|
||||
styleName='subscription-submit-button'
|
||||
type='submit'
|
||||
disabled={this.state.subscriptionFormStatus === 'sending'}
|
||||
>
|
||||
Subscribe
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
)}
|
||||
<hr />
|
||||
|
||||
<div styleName='group-header--sub'>{i18n.__('About')}</div>
|
||||
|
||||
<div styleName='top'>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user