lbry-desktop/ui/js/page/auth/view.jsx

96 lines
2.8 KiB
React
Raw Normal View History

2017-07-19 01:00:13 +02:00
import React from "react";
import { BusyMessage } from "component/common";
2017-07-29 18:58:31 +02:00
import Link from "component/link";
2017-07-19 01:00:13 +02:00
import UserEmailNew from "component/userEmailNew";
import UserEmailVerify from "component/userEmailVerify";
import UserVerify from "component/userVerify";
export class AuthPage extends React.PureComponent {
componentWillMount() {
this.navigateIfAuthenticated(this.props);
}
componentWillReceiveProps(nextProps) {
this.navigateIfAuthenticated(nextProps);
}
navigateIfAuthenticated(props) {
const { isPending, user } = props;
if (
!isPending &&
user &&
user.has_verified_email &&
(user.is_reward_approved || user.is_identity_verified)
2017-07-19 01:00:13 +02:00
) {
2017-07-19 17:09:40 +02:00
props.navigate(props.pathAfterAuth);
2017-07-19 01:00:13 +02:00
}
}
getTitle() {
const { email, isPending, isVerificationCandidate, user } = this.props;
if (isPending || (user && !user.has_verified_email && !email)) {
return __("Welcome to LBRY");
} else if (user && !user.has_verified_email) {
return __("Confirm Email");
} else if (user && !user.is_identity_verified && !user.is_reward_approved) {
2017-07-19 01:00:13 +02:00
return __("Confirm Identity");
} else {
return __("Welcome to LBRY");
}
}
renderMain() {
const { email, isPending, isVerificationCandidate, user } = this.props;
if (isPending) {
return <BusyMessage message={__("Authenticating")} />;
} else if (user && !user.has_verified_email && !email) {
return <UserEmailNew />;
} else if (user && !user.has_verified_email) {
return <UserEmailVerify />;
} else if (user && !user.is_identity_verified) {
return <UserVerify />;
} else {
return <span className="empty">{__("No further steps.")}</span>;
}
}
render() {
2017-07-29 18:58:31 +02:00
const { email, user, isPending, navigate } = this.props;
2017-07-19 01:00:13 +02:00
return (
<main className="">
<section className="card card--form">
<div className="card__title-primary">
<h1>{this.getTitle()}</h1>
</div>
<div className="card__content">
{!isPending &&
!email &&
2017-08-03 01:17:28 +02:00
user &&
2017-07-20 21:03:01 +02:00
!user.has_verified_email &&
2017-07-19 01:00:13 +02:00
<p>
{__("Create a verified identity and receive LBC rewards.")}
</p>}
{this.renderMain()}
</div>
<div className="card__content">
<div className="help">
{__(
2017-07-28 03:13:12 +02:00
"This information is disclosed only to LBRY, Inc. and not to the LBRY network. It is only required to earn LBRY rewards."
2017-07-29 18:58:31 +02:00
) + " "}
<Link
onClick={() => navigate("/discover")}
label={__("Return home")}
/>.
2017-07-19 01:00:13 +02:00
</div>
</div>
</section>
</main>
);
}
}
export default AuthPage;