lbry-desktop/src/renderer/component/userEmailNew/view.jsx

79 lines
1.8 KiB
React
Raw Normal View History

2018-03-30 02:43:47 +02:00
// @flow
import * as React from 'react';
import { FormField, Form, FormRow, Submit } from 'component/common/form';
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();
this.state = {
email: '',
};
2018-03-30 02:43:47 +02:00
(this: any).handleSubmit = this.handleSubmit.bind(this);
(this: any).handleEmailChanged = this.handleEmailChanged.bind(this);
}
2018-03-30 02:43:47 +02:00
handleEmailChanged(event: SyntheticInputEvent<*>) {
this.setState({
email: event.target.value,
});
}
handleSubmit() {
const { email } = this.state;
2018-03-30 02:43:47 +02:00
const { addUserEmail } = this.props;
addUserEmail(email);
}
render() {
const { cancelButton, errorMessage, isPending } = this.props;
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>
{__("We'll let you know about LBRY updates, security issues, and great new content.")}
2017-08-26 05:21:26 +02:00
</p>
<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}>
<FormRow>
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-03-30 02:43:47 +02:00
<div className="card__actions">
<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-08 23:15:34 +02:00
export default UserEmailNew;