lbry-desktop/ui/js/component/authOverlay/view.jsx

91 lines
2.5 KiB
React
Raw Normal View History

2017-06-01 18:20:12 +02:00
import React from "react";
2017-06-08 02:56:52 +02:00
import lbryio from "lbryio.js";
2017-06-01 18:20:12 +02:00
import ModalPage from "component/modal-page.js";
2017-06-08 02:56:52 +02:00
import Auth from "component/auth";
import Link from "component/link";
2017-06-22 02:09:30 +02:00
import { getLocal, setLocal } from "utils";
2017-06-01 18:20:12 +02:00
export class AuthOverlay extends React.PureComponent {
2017-06-01 18:20:12 +02:00
constructor(props) {
super(props);
this.state = {
showNoEmailConfirm: false,
};
}
2017-06-08 02:56:52 +02:00
componentWillReceiveProps(nextProps) {
2017-06-22 02:09:30 +02:00
if (
this.props.isShowing &&
!this.props.isPending &&
2017-06-28 20:00:10 +02:00
!nextProps.hasNewUserReward &&
2017-06-22 02:09:30 +02:00
!nextProps.isShowing /* && !getLocal("welcome_screen_shown")*/
) {
setLocal("welcome_screen_shown", true);
2017-06-08 02:56:52 +02:00
setTimeout(() => this.props.openWelcomeModal(), 1);
}
}
2017-06-01 18:20:12 +02:00
onEmailSkipClick() {
2017-06-08 02:56:52 +02:00
this.setState({ showNoEmailConfirm: true });
2017-06-01 18:20:12 +02:00
}
onEmailSkipConfirm() {
2017-06-08 02:56:52 +02:00
this.props.userEmailDecline();
2017-06-01 18:20:12 +02:00
}
render() {
2017-06-08 02:56:52 +02:00
if (!lbryio.enabled) {
return null;
}
2017-06-08 23:15:34 +02:00
const { isPending, isShowing, hasEmail } = this.props;
2017-06-03 01:09:52 +02:00
2017-06-08 02:56:52 +02:00
if (isShowing) {
return (
<ModalPage
className="modal-page--full"
isOpen={true}
contentLabel="Authentication"
>
<h1>LBRY Early Access</h1>
<Auth />
{isPending
? ""
: <div className="form-row-submit">
2017-06-08 23:15:34 +02:00
{!hasEmail && this.state.showNoEmailConfirm
? <div className="help form-input-width">
<p>
2017-06-08 02:56:52 +02:00
{__(
"If you continue without an email, you will be ineligible to earn free LBC rewards, as well as unable to receive security related communications."
)}
</p>
<Link
onClick={() => {
this.onEmailSkipConfirm();
}}
label={__("Continue without email")}
/>
</div>
: <Link
2017-06-08 23:15:34 +02:00
className={"button-text-help"}
2017-06-08 02:56:52 +02:00
onClick={() => {
2017-06-08 23:15:34 +02:00
hasEmail
? this.onEmailSkipConfirm()
: this.onEmailSkipClick();
2017-06-08 02:56:52 +02:00
}}
2017-06-08 23:15:34 +02:00
label={
hasEmail ? __("Skip for now") : __("Do I have to?")
}
2017-06-08 02:56:52 +02:00
/>}
</div>}
</ModalPage>
);
2017-06-01 18:20:12 +02:00
}
2017-06-08 02:56:52 +02:00
return null;
2017-06-01 18:20:12 +02:00
}
}
2017-06-08 02:56:52 +02:00
export default AuthOverlay;