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

91 lines
2.5 KiB
React
Raw Normal View History

2017-06-01 12:20:12 -04:00
import React from "react";
2017-06-07 20:56:52 -04:00
import lbryio from "lbryio.js";
2017-06-01 12:20:12 -04:00
import ModalPage from "component/modal-page.js";
2017-06-07 20:56:52 -04:00
import Auth from "component/auth";
import Link from "component/link";
2017-06-21 20:09:30 -04:00
import { getLocal, setLocal } from "utils";
2017-06-01 12:20:12 -04:00
export class AuthOverlay extends React.PureComponent {
2017-06-01 12:20:12 -04:00
constructor(props) {
super(props);
this.state = {
showNoEmailConfirm: false,
};
}
2017-06-07 20:56:52 -04:00
componentWillReceiveProps(nextProps) {
2017-06-21 20:09:30 -04:00
if (
this.props.isShowing &&
!this.props.isPending &&
2017-06-28 14:00:10 -04:00
!nextProps.hasNewUserReward &&
2017-06-21 20:09:30 -04:00
!nextProps.isShowing /* && !getLocal("welcome_screen_shown")*/
) {
setLocal("welcome_screen_shown", true);
2017-06-07 20:56:52 -04:00
setTimeout(() => this.props.openWelcomeModal(), 1);
}
}
2017-06-01 12:20:12 -04:00
onEmailSkipClick() {
2017-06-07 20:56:52 -04:00
this.setState({ showNoEmailConfirm: true });
2017-06-01 12:20:12 -04:00
}
onEmailSkipConfirm() {
2017-06-07 20:56:52 -04:00
this.props.userEmailDecline();
2017-06-01 12:20:12 -04:00
}
render() {
2017-06-07 20:56:52 -04:00
if (!lbryio.enabled) {
return null;
}
2017-06-08 17:15:34 -04:00
const { isPending, isShowing, hasEmail } = this.props;
2017-06-02 19:09:52 -04:00
2017-06-07 20:56:52 -04: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 17:15:34 -04:00
{!hasEmail && this.state.showNoEmailConfirm
? <div className="help form-input-width">
<p>
2017-06-07 20:56:52 -04: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 17:15:34 -04:00
className={"button-text-help"}
2017-06-07 20:56:52 -04:00
onClick={() => {
2017-06-08 17:15:34 -04:00
hasEmail
? this.onEmailSkipConfirm()
: this.onEmailSkipClick();
2017-06-07 20:56:52 -04:00
}}
2017-06-08 17:15:34 -04:00
label={
hasEmail ? __("Skip for now") : __("Do I have to?")
}
2017-06-07 20:56:52 -04:00
/>}
</div>}
</ModalPage>
);
2017-06-01 12:20:12 -04:00
}
2017-06-07 20:56:52 -04:00
return null;
2017-06-01 12:20:12 -04:00
}
}
2017-06-07 20:56:52 -04:00
export default AuthOverlay;