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

80 lines
2 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>
<header className="card__header">
<h2 className="card__title">{__("Don't Miss Out")}</h2>
<p className="card__subtitle">
{__("We'll let you know about LBRY updates, security issues, and great new content.")}
</p>
</header>
<Form className="card__content" 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 || !this.state.email} />
{cancelButton}
</div>
</Form>
<p className="help">
{__('Your email address will never be sold and you can unsubscribe at any time.')}
</p>
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;