import React from "react";
import lbryio from "lbryio";
import { BusyMessage, CreditAmount, Icon } from "component/common";
import SubHeader from "component/subHeader";
import Auth from "component/auth";
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 && Object.keys(rewards).length < 1) fetchRewards();
}
render() {
const {
fetching,
isEligible,
isVerificationCandidate,
hasEmail,
rewards,
} = this.props;
let content,
isCard = false;
if (!hasEmail || isVerificationCandidate) {
content = (
{__(
"Additional information is required to be eligible for the rewards program."
)}
);
isCard = true;
} else if (!isEligible) {
isCard = true;
content = (
{__("You are not eligible to claim rewards.")}
);
} else if (fetching) {
content = ;
} else if (rewards.length > 0) {
content = rewards.map(reward =>
);
} else {
content = {__("Failed to load rewards.")}
;
}
return (
{isCard
?
: content}
);
}
}
export default RewardsPage;