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

86 lines
2.2 KiB
React
Raw Normal View History

2018-03-30 02:43:47 +02:00
// @flow
import * as React from 'react';
2019-02-13 17:27:20 +01:00
import { FormField, Form, Submit } from 'component/common/form';
2019-03-13 20:17:17 +01:00
import { Lbryio } from 'lbryinc';
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);
2019-03-13 20:17:17 +01:00
// @if TARGET='web'
Lbryio.call('user_tag', 'edit', { add: 'lbrytv' });
// @endif
}
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">
2019-03-13 20:17:17 +01:00
{/* @if TARGET='app' */}
{__("We'll let you know about LBRY updates, security issues, and great new content.")}
2019-03-13 20:17:17 +01:00
{/* @endif */}
{/* @if TARGET='web' */}
{__(
'Stay up to date with lbry.tv and be the first to know about the progress we make.'
)}
{/* @endif */}
</p>
</header>
<Form className="card__content" onSubmit={this.handleSubmit}>
2019-02-13 17:27:20 +01:00
<FormField
type="email"
label="Email"
placeholder="youremail@example.org"
name="email"
value={this.state.email}
error={errorMessage}
onChange={this.handleEmailChanged}
inputButton={<Submit label="Submit" disabled={isPending || !this.state.email} />}
/>
</Form>
2019-02-13 17:27:20 +01:00
<div className="card__actions">{cancelButton}</div>
<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;