// @flow import * as PAGES from 'constants/pages'; import React, { PureComponent } from 'react'; import BusyIndicator from 'component/common/busy-indicator'; import RewardListClaimed from 'component/rewardListClaimed'; import RewardTile from 'component/rewardTile'; import Button from 'component/button'; import Page from 'component/page'; import classnames from 'classnames'; import { rewards as REWARD_TYPES } from 'lbryinc'; import RewardAuthIntro from 'component/rewardAuthIntro'; import Card from 'component/common/card'; import I18nMessage from 'component/i18nMessage'; type Props = { doAuth: () => void, fetchRewards: () => void, fetchUser: () => void, fetching: boolean, rewards: Array, claimed: Array, user: ?{ is_identity_verified: boolean, is_reward_approved: boolean, primary_email: string, has_verified_email: boolean, }, daemonSettings: { share_usage_data: boolean, }, }; class RewardsPage extends PureComponent { componentDidMount() { this.props.fetchRewards(); } renderPageHeader() { const { user, daemonSettings, fetchUser } = this.props; const rewardsEnabled = IS_WEB || (daemonSettings && daemonSettings.share_usage_data); if (user && !user.is_reward_approved && rewardsEnabled) { if (!user.primary_email || !user.has_verified_email || !user.is_identity_verified) { return ; } return (

{__( 'This account must undergo review before you can participate in the rewards program. Not all users and regions may qualify.' )}{' '} {__('This can take anywhere from a few hours to several days. Please be patient.')}

{__( 'We apologize for this inconvenience, but have added this additional step to prevent abuse. Users on VPN or shared connections will continue to see this message and are not not eligible for Rewards.' )}

, }} > Please review the %rewards_faq% for eligibility, and send us an email to help@lbry.com if you continue to see this message. You can continue to use LBRY without this feature. {`${__('Enjoy all the awesome free content in the meantime!')}`}

} actions={
} /> ); } return null; } renderCustomRewardCode() { return ( ); } renderUnclaimedRewards() { const { fetching, rewards, user, daemonSettings, claimed } = this.props; if (!IS_WEB && daemonSettings && !daemonSettings.share_usage_data) { return (

{__('Rewards Disabled')}

}}> Rewards are currently disabled for your account. Turn on diagnostic data sharing, in %settings%, to re-enable them.

); } else if (fetching) { return ; } else if (user === null) { return (

{__('This application is unable to earn rewards due to an authentication failure.')}

); } else if (!rewards || rewards.length <= 0) { return ( } /> ); } const isNotEligible = !user || !user.primary_email || !user.has_verified_email || !user.is_reward_approved; return (
{rewards.map(reward => ( ))} {this.renderCustomRewardCode()}
); } render() { return ( {this.renderPageHeader()} {this.renderUnclaimedRewards()} {} ); } } export default RewardsPage;