// @flow import React, { PureComponent, Fragment } 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 UnsupportedOnWeb from 'component/common/unsupported-on-web'; type Props = { doAuth: () => 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 { renderPageHeader() { const { user, daemonSettings } = this.props; if (user && !user.is_reward_approved && daemonSettings && daemonSettings.share_usage_data) { if (!user.primary_email || !user.has_verified_email || !user.is_identity_verified) { return ( !IS_WEB && (

{__('Rewards Approval to Earn Credits (LBC)')}

{__( 'This step is optional. You can continue to use this app without rewards, but LBC may be needed for some tasks.' )}{' '}

) ); } return (

{__('This account must undergo review before you can participate in the rewards program.')}{' '} {__('This can take anywhere from several minutes to several days.')}

{__('We apologize for this inconvenience, but have added this additional step to prevent fraud.')}

{`${__('If you continue to see this message, send us an email to help@lbry.com.')} ${__( 'Please enjoy free content in the meantime!' )}`}

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

{__('Disabled')}

{__('Rewards are currently disabled for your account. Turn on diagnostic data sharing, in')}{' '}

); } 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 (

{__('No Rewards Available')}

{claimed && claimed.length ? __( "You have claimed all available rewards! We're regularly adding more so be sure to check back later." ) : __('There are no rewards available at this time, please check back later.')}

{this.renderCustomRewardCode()}
); } const isNotEligible = !user || !user.primary_email || !user.has_verified_email || !user.is_reward_approved; return (
{rewards.map(reward => ( ))} {this.renderCustomRewardCode()}
); } render() { return ( {IS_WEB && } {this.renderPageHeader()} {this.renderUnclaimedRewards()} {} ); } } export default RewardsPage;