import React from "react"; import { BusyMessage, CreditAmount, Icon } from "component/common"; import SubHeader from "component/subHeader"; import Link from "component/link"; import RewardLink from "component/rewardLink"; const RewardTile = props => { const { reward } = props; const claimed = !!reward.transaction_id; return (

{reward.reward_title}

{claimed ? {__("Reward claimed.")} : }
{reward.reward_description}
); }; class RewardsPage extends React.PureComponent { componentDidMount() { this.fetchRewards(this.props); } componentWillReceiveProps(nextProps) { this.fetchRewards(nextProps); } fetchRewards(props) { const { fetching, rewards, fetchRewards } = props; if (!fetching && (!rewards || !rewards.length)) { fetchRewards(); } } render() { const { doAuth, fetching, navigate, rewards, user } = this.props; let content, cardHeader; if (fetching) { content = (
); } else if (rewards.length > 0) { content = (
{rewards.map(reward => )}
); } else { content = (
{__("Failed to load rewards.")}
); } if (user && !user.is_reward_approved) { if ( !user.primary_email || !user.has_verified_email || !user.is_identity_verified ) { cardHeader = (

{__("Only verified accounts are eligible to earn rewards.")}

); } else { cardHeader = (

{__( "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." )}

{__("You will receive an email when this process is complete.") + " " + __("Please enjoy free content in the meantime!")}

navigate("/discover")} button="primary" label="Return Home" />

); } } else if (user === null) { cardHeader = (

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

); } return (
{cardHeader &&
{cardHeader}
} {content}
); } } export default RewardsPage;