fix rewards verification for users that skipped it on first run
This commit is contained in:
parent
2677cd17d8
commit
0c84e6296e
7 changed files with 26 additions and 60 deletions
|
@ -32,7 +32,7 @@ function RewardAuthIntro(props: Props) {
|
|||
actions={
|
||||
<Button
|
||||
button="primary"
|
||||
navigate={`/$/${PAGES.AUTH}?redirect=/$/${PAGES.REWARDS}`}
|
||||
navigate={`/$/${PAGES.REWARDS_VERIFY}?redirect=/$/${PAGES.REWARDS}`}
|
||||
label={__('Unlock Rewards')}
|
||||
/>
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import EmbedWrapperPage from 'page/embedWrapper';
|
|||
import TopPage from 'page/top';
|
||||
import Welcome from 'page/welcome';
|
||||
import CreatorDashboard from 'page/creatorDashboard';
|
||||
import RewardsVerifyPage from 'page/rewardsVerify';
|
||||
import { parseURI } from 'lbry-redux';
|
||||
import { SITE_TITLE, WELCOME_VERSION } from 'config';
|
||||
|
||||
|
@ -182,7 +183,8 @@ function AppRouter(props: Props) {
|
|||
<PrivateRoute {...props} path={`/$/${PAGES.CREATOR_DASHBOARD}`} component={CreatorDashboard} />
|
||||
<PrivateRoute {...props} path={`/$/${PAGES.PUBLISH}`} component={PublishPage} />
|
||||
<PrivateRoute {...props} path={`/$/${PAGES.REPORT}`} component={ReportPage} />
|
||||
<PrivateRoute {...props} path={`/$/${PAGES.REWARDS}`} component={RewardsPage} />
|
||||
<PrivateRoute {...props} path={`/$/${PAGES.REWARDS}`} exact component={RewardsPage} />
|
||||
<PrivateRoute {...props} path={`/$/${PAGES.REWARDS_VERIFY}`} component={RewardsVerifyPage} />
|
||||
<PrivateRoute {...props} path={`/$/${PAGES.TRANSACTIONS}`} component={TransactionHistoryPage} />
|
||||
<PrivateRoute {...props} path={`/$/${PAGES.LIBRARY}`} component={LibraryPage} />
|
||||
<PrivateRoute {...props} path={`/$/${PAGES.TAGS_FOLLOWING_MANAGE}`} component={TagsFollowingManagePage} />
|
||||
|
|
|
@ -15,6 +15,7 @@ exports.PUBLISHED = 'published';
|
|||
exports.GET_CREDITS = 'getcredits';
|
||||
exports.REPORT = 'report';
|
||||
exports.REWARDS = 'rewards';
|
||||
exports.REWARDS_VERIFY = 'rewards/verify';
|
||||
exports.SEND = 'send';
|
||||
exports.SETTINGS = 'settings';
|
||||
exports.SHOW = 'show';
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
import { connect } from 'react-redux';
|
||||
import { selectEmailToVerify, selectUser } from 'lbryinc';
|
||||
import AuthPage from './view';
|
||||
|
||||
const select = state => ({
|
||||
email: selectEmailToVerify(state),
|
||||
user: selectUser(state),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
select,
|
||||
null
|
||||
)(AuthPage);
|
|
@ -1,45 +0,0 @@
|
|||
// @flow
|
||||
import React from 'react';
|
||||
import UserEmail from 'component/userEmail';
|
||||
import UserVerify from 'component/userVerify';
|
||||
import Page from 'component/page';
|
||||
|
||||
type Props = {
|
||||
isPending: boolean,
|
||||
email: string,
|
||||
location: UrlLocation,
|
||||
history: { push: string => void },
|
||||
user: ?{
|
||||
has_verified_email: boolean,
|
||||
is_reward_approved: boolean,
|
||||
is_identity_verified: boolean,
|
||||
},
|
||||
};
|
||||
|
||||
class AuthPage extends React.PureComponent<Props> {
|
||||
componentDidMount() {
|
||||
this.navigateIfAuthenticated(this.props);
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
this.navigateIfAuthenticated(this.props);
|
||||
}
|
||||
|
||||
navigateIfAuthenticated = (props: Props) => {
|
||||
const { isPending, user, location, history } = props;
|
||||
if (!isPending && user && user.has_verified_email && (user.is_reward_approved || user.is_identity_verified)) {
|
||||
const { search } = location;
|
||||
const urlParams = new URLSearchParams(search);
|
||||
const redirectTo = urlParams.get('redirect');
|
||||
const path = redirectTo ? `/$/${redirectTo}` : '/';
|
||||
history.push(path);
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const { user, email } = this.props;
|
||||
return <Page>{user && email && user.has_verified_email ? <UserVerify /> : <UserEmail />}</Page>;
|
||||
}
|
||||
}
|
||||
|
||||
export default AuthPage;
|
4
ui/page/rewardsVerify/index.js
Normal file
4
ui/page/rewardsVerify/index.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
import { connect } from 'react-redux';
|
||||
import AuthPage from './view';
|
||||
|
||||
export default connect(null, null)(AuthPage);
|
17
ui/page/rewardsVerify/view.jsx
Normal file
17
ui/page/rewardsVerify/view.jsx
Normal file
|
@ -0,0 +1,17 @@
|
|||
// @flow
|
||||
import React from 'react';
|
||||
import UserVerify from 'component/userVerify';
|
||||
import Page from 'component/page';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
function RewardsVerifyPage() {
|
||||
const { goBack } = useHistory();
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<UserVerify onSkip={() => goBack()} />
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
|
||||
export default RewardsVerifyPage;
|
Loading…
Reference in a new issue