2018-03-29 20:43:47 -04:00
|
|
|
// @flow
|
|
|
|
import * as React from 'react';
|
|
|
|
import { FormField, Form, FormRow, Submit } from 'component/common/form';
|
2017-06-01 20:51:52 -04:00
|
|
|
|
2018-03-29 20:43:47 -04:00
|
|
|
type Props = {
|
|
|
|
cancelButton: React.Node,
|
|
|
|
errorMessage: ?string,
|
|
|
|
isPending: boolean,
|
|
|
|
addUserEmail: string => void,
|
|
|
|
};
|
|
|
|
|
|
|
|
type State = {
|
|
|
|
email: string,
|
|
|
|
};
|
|
|
|
|
|
|
|
class UserEmailNew extends React.PureComponent<Props, State> {
|
|
|
|
constructor() {
|
|
|
|
super();
|
2017-06-01 20:51:52 -04:00
|
|
|
|
|
|
|
this.state = {
|
2017-12-21 18:08:54 -03:00
|
|
|
email: '',
|
2017-06-01 20:51:52 -04:00
|
|
|
};
|
2018-03-29 20:43:47 -04:00
|
|
|
|
|
|
|
(this: any).handleSubmit = this.handleSubmit.bind(this);
|
|
|
|
(this: any).handleEmailChanged = this.handleEmailChanged.bind(this);
|
2017-06-01 20:51:52 -04:00
|
|
|
}
|
|
|
|
|
2018-03-29 20:43:47 -04:00
|
|
|
handleEmailChanged(event: SyntheticInputEvent<*>) {
|
2017-06-01 20:51:52 -04:00
|
|
|
this.setState({
|
|
|
|
email: event.target.value,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-09-10 19:25:24 -06:00
|
|
|
handleSubmit() {
|
|
|
|
const { email } = this.state;
|
2018-03-29 20:43:47 -04:00
|
|
|
const { addUserEmail } = this.props;
|
|
|
|
addUserEmail(email);
|
2017-06-01 20:51:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2017-12-29 15:43:51 -08:00
|
|
|
const { cancelButton, errorMessage, isPending } = this.props;
|
2017-06-01 20:51:52 -04:00
|
|
|
|
2017-06-08 17:15:34 -04:00
|
|
|
return (
|
2019-01-08 01:45:20 -05:00
|
|
|
<React.Fragment>
|
2017-08-25 23:21:26 -04:00
|
|
|
<p>
|
2017-12-29 15:43:51 -08:00
|
|
|
{__("We'll let you know about LBRY updates, security issues, and great new content.")}
|
2017-08-25 23:21:26 -04:00
|
|
|
</p>
|
2018-12-19 00:44:53 -05:00
|
|
|
|
|
|
|
<p>
|
|
|
|
{__(
|
|
|
|
'In addition, your email address will never be sold and you can unsubscribe at any time.'
|
|
|
|
)}
|
|
|
|
</p>
|
|
|
|
|
2018-03-29 20:43:47 -04:00
|
|
|
<Form onSubmit={this.handleSubmit}>
|
2018-09-26 13:48:07 -04:00
|
|
|
<FormRow padded>
|
2018-03-29 20:43:47 -04:00
|
|
|
<FormField
|
|
|
|
stretch
|
|
|
|
type="email"
|
|
|
|
label="Email"
|
|
|
|
placeholder="youremail@example.org"
|
|
|
|
name="email"
|
|
|
|
value={this.state.email}
|
2018-03-30 01:40:20 -04:00
|
|
|
error={errorMessage}
|
2018-03-29 20:43:47 -04:00
|
|
|
onChange={this.handleEmailChanged}
|
|
|
|
/>
|
|
|
|
</FormRow>
|
2018-12-19 00:44:53 -05:00
|
|
|
|
2018-03-29 20:43:47 -04:00
|
|
|
<div className="card__actions">
|
2017-12-07 13:07:30 -05:00
|
|
|
<Submit label="Submit" disabled={isPending} />
|
|
|
|
{cancelButton}
|
|
|
|
</div>
|
|
|
|
</Form>
|
2019-01-08 01:45:20 -05:00
|
|
|
</React.Fragment>
|
2017-06-08 17:15:34 -04:00
|
|
|
);
|
2017-06-01 20:51:52 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-08 17:15:34 -04:00
|
|
|
export default UserEmailNew;
|