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