2018-03-30 02:43:47 +02:00
|
|
|
// @flow
|
|
|
|
import * as React from 'react';
|
2019-07-08 18:51:53 +02:00
|
|
|
import { FormField, Form } from 'component/common/form';
|
|
|
|
import Button from 'component/button';
|
2019-03-13 20:17:17 +01:00
|
|
|
import { Lbryio } from 'lbryinc';
|
2019-08-14 18:28:13 +02:00
|
|
|
import analytics from 'analytics';
|
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);
|
2019-08-14 18:28:13 +02:00
|
|
|
analytics.emailProvidedEvent();
|
2019-03-13 20:17:17 +01:00
|
|
|
|
|
|
|
// @if TARGET='web'
|
|
|
|
Lbryio.call('user_tag', 'edit', { add: 'lbrytv' });
|
|
|
|
// @endif
|
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>
|
2019-07-21 23:31:22 +02:00
|
|
|
<h2 className="card__title">{__('Verify Your Email')}</h2>
|
|
|
|
<p className="card__subtitle">
|
|
|
|
{/* @if TARGET='app' */}
|
|
|
|
{__("We'll let you know about LBRY updates, security issues, and great new content.")}
|
|
|
|
{/* @endif */}
|
|
|
|
{/* @if TARGET='web' */}
|
|
|
|
{__('Stay up to date with lbry.tv and be the first to know about the progress we make.')}
|
|
|
|
{/* @endif */}
|
|
|
|
</p>
|
2018-12-19 06:44:53 +01:00
|
|
|
|
2019-07-21 23:31:22 +02:00
|
|
|
<Form 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}
|
2019-07-08 18:51:53 +02:00
|
|
|
inputButton={
|
|
|
|
<Button type="submit" button="inverse" label="Submit" disabled={isPending || !this.state.email} />
|
|
|
|
}
|
2019-02-13 17:27:20 +01:00
|
|
|
/>
|
2017-12-07 19:07:30 +01:00
|
|
|
</Form>
|
2019-02-13 17:27:20 +01:00
|
|
|
<div className="card__actions">{cancelButton}</div>
|
2019-05-07 23:38:29 +02:00
|
|
|
<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-02 02:51:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-08 23:15:34 +02:00
|
|
|
export default UserEmailNew;
|