lbry-desktop/ui/js/page/rewards/view.jsx

93 lines
2.3 KiB
React
Raw Normal View History

2017-06-08 02:56:52 +02:00
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";
2017-05-26 10:53:32 +02:00
2017-06-08 02:56:52 +02:00
const RewardTile = props => {
const { reward } = props;
2017-05-26 10:53:32 +02:00
2017-06-08 02:56:52 +02:00
const claimed = !!reward.transaction_id;
2017-05-26 10:53:32 +02:00
return (
<section className="card">
<div className="card__inner">
<div className="card__title-primary">
<CreditAmount amount={reward.reward_amount} />
<h3>{reward.reward_title}</h3>
2017-05-26 10:53:32 +02:00
</div>
<div className="card__actions">
{claimed
? <span><Icon icon="icon-check" /> Reward claimed.</span>
2017-06-08 02:56:52 +02:00
: <RewardLink reward_type={reward.reward_type} />}
2017-05-26 10:53:32 +02:00
</div>
<div className="card__content">{reward.reward_description}</div>
</div>
</section>
2017-06-08 02:56:52 +02:00
);
};
2017-05-26 10:53:32 +02:00
2017-06-08 02:56:52 +02:00
const RewardsPage = props => {
2017-05-26 10:53:32 +02:00
const {
fetching,
2017-06-03 01:09:52 +02:00
isEligible,
2017-06-08 02:56:52 +02:00
isVerificationCandidate,
hasEmail,
2017-05-26 10:53:32 +02:00
rewards,
2017-06-08 02:56:52 +02:00
} = props;
let content,
isCard = false;
2017-05-26 10:53:32 +02:00
2017-06-08 02:56:52 +02:00
if (!hasEmail || isVerificationCandidate) {
content = (
<div>
<p>
{__(
"Additional information is required to be eligible for the rewards program."
)}
</p>
<Auth />
</div>
);
isCard = true;
} else if (!isEligible) {
isCard = true;
content = (
<div className="empty">
<p>{__("You are not eligible to claim rewards.")}</p>
<p>
To become eligible, email
{" "}<Link href="mailto:help@lbry.io" label="help@lbry.io" /> with a
link to a public social media profile.
</p>
</div>
);
2017-06-03 01:09:52 +02:00
} else if (fetching) {
2017-06-08 02:56:52 +02:00
content = <BusyMessage message="Fetching rewards" />;
2017-06-03 01:09:52 +02:00
} else if (rewards.length > 0) {
2017-06-08 02:56:52 +02:00
content = rewards.map(reward =>
<RewardTile key={reward.reward_type} reward={reward} />
);
2017-06-03 01:09:52 +02:00
} else {
2017-06-08 02:56:52 +02:00
content = <div className="empty">{__("Failed to load rewards.")}</div>;
2017-05-26 10:53:32 +02:00
}
return (
<main className="main--single-column">
<SubHeader />
2017-06-08 02:56:52 +02:00
{isCard
? <section className="card">
<div className="card__content">
{content}
</div>
</section>
: content}
2017-05-26 10:53:32 +02:00
</main>
2017-06-08 02:56:52 +02:00
);
};
2017-05-26 10:53:32 +02:00
export default RewardsPage;