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

85 lines
2.3 KiB
React
Raw Normal View History

2018-03-30 02:43:47 +02:00
// @flow
import * as React from 'react';
import { FormField, Form } from 'component/common/form';
import Button from 'component/button';
2019-03-13 20:17:17 +01:00
import { Lbryio } from 'lbryinc';
import analytics from 'analytics';
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);
analytics.emailProvidedEvent();
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>
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>
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}
inputButton={
<Button type="submit" button="inverse" label="Submit" disabled={isPending || !this.state.email} />
}
2019-02-13 17:27:20 +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-08 23:15:34 +02:00
export default UserEmailNew;