rewards redirect fix for manually approved users

This commit is contained in:
Sean Yesmunt 2020-07-03 13:16:54 -04:00
parent 70c6034662
commit cfd5d46802
3 changed files with 28 additions and 4 deletions

View file

@ -32,8 +32,15 @@ type Props = {
class RewardsPage extends PureComponent<Props> {
componentDidMount() {
this.props.fetchRewards();
const { user, fetchUser, fetchRewards } = this.props;
const rewardsApproved = user && user.is_reward_approved;
fetchRewards();
if (!rewardsApproved) {
fetchUser();
}
}
renderPageHeader() {
const { user, daemonSettings, fetchUser } = this.props;
const rewardsEnabled = IS_WEB || (daemonSettings && daemonSettings.share_usage_data);

View file

@ -1,4 +1,9 @@
import { connect } from 'react-redux';
import AuthPage from './view';
import { selectUser } from 'redux/selectors/user';
import RewardsVerifyPage from './view';
export default connect(null, null)(AuthPage);
const select = state => ({
user: selectUser(state),
});
export default connect(select, null)(RewardsVerifyPage);

View file

@ -4,8 +4,20 @@ import UserVerify from 'component/userVerify';
import Page from 'component/page';
import { useHistory } from 'react-router-dom';
function RewardsVerifyPage() {
type Props = {
user: ?User,
};
function RewardsVerifyPage(props: Props) {
const { user } = props;
const { goBack } = useHistory();
const rewardsApproved = user && user.is_reward_approved;
React.useEffect(() => {
if (rewardsApproved) {
goBack();
}
}, [rewardsApproved]);
return (
<Page>