lbry-desktop/ui/component/inviteNew/view.jsx

89 lines
2.4 KiB
React
Raw Normal View History

// @flow
import React from 'react';
2018-04-11 03:58:34 +07:00
import Button from 'component/button';
2019-06-17 16:32:38 -04:00
import { Form, FormField } from 'component/common/form';
2019-02-20 11:18:59 -05:00
import CopyableText from 'component/copyableText';
2019-09-26 12:07:11 -04:00
import Card from 'component/common/card';
2020-01-03 10:06:26 -05:00
import I18nMessage from 'component/i18nMessage';
2017-08-17 23:31:44 -04:00
type FormState = {
email: string,
};
2019-11-22 16:13:00 -05:00
type Props = {
errorMessage: ?string,
inviteNew: string => void,
isPending: boolean,
referralLink: string,
};
class InviteNew extends React.PureComponent<Props, FormState> {
2018-03-26 14:32:43 -07:00
constructor() {
super();
2017-08-17 23:31:44 -04:00
this.state = {
email: '',
2017-08-17 23:31:44 -04:00
};
2018-03-26 14:32:43 -07:00
(this: any).handleSubmit = this.handleSubmit.bind(this);
2017-08-17 23:31:44 -04:00
}
2019-11-22 16:13:00 -05:00
handleEmailChanged(event: any) {
2017-08-17 23:31:44 -04:00
this.setState({
email: event.target.value,
});
}
handleSubmit() {
const { email } = this.state;
this.props.inviteNew(email);
2017-08-17 23:31:44 -04:00
}
render() {
2019-11-22 16:13:00 -05:00
const { errorMessage, isPending, referralLink } = this.props;
2017-08-17 23:31:44 -04:00
return (
2019-09-26 12:07:11 -04:00
<Card
title={__('Invite a Friend')}
subtitle={__('When your friends start using LBRY, the network gets stronger!')}
actions={
2019-09-26 12:07:11 -04:00
<React.Fragment>
2019-11-22 16:13:00 -05:00
<Form onSubmit={this.handleSubmit}>
<FormField
type="text"
label="Email"
placeholder="youremail@example.org"
name="email"
value={this.state.email}
error={errorMessage}
inputButton={
<Button button="secondary" type="submit" label="Invite" disabled={isPending || !this.state.email} />
}
onChange={event => {
this.handleEmailChanged(event);
}}
/>
<CopyableText label={__('Or share this link with your friends')} copyable={referralLink} />
2019-07-21 17:31:22 -04:00
2019-11-22 16:13:00 -05:00
<p className="help">
2020-01-03 10:06:26 -05:00
<I18nMessage
tokens={{
rewards_link: <Button button="link" navigate="/$/rewards" label={__('rewards')} />,
referral_faq_link: <Button button="link" label={__('FAQ')} href="https://lbry.com/faq/referrals" />,
}}
>
Earn %rewards_link% for inviting your friends. Read our %referral_faq_link% to learn more about
referrals.
</I18nMessage>
2019-11-22 16:13:00 -05:00
</p>
</Form>
2019-09-26 12:07:11 -04:00
</React.Fragment>
}
/>
2017-08-17 23:31:44 -04:00
);
}
}
export default InviteNew;