lbry-desktop/ui/component/inviteList/view.jsx

100 lines
3.1 KiB
React
Raw Permalink Normal View History

2018-09-24 05:44:42 +02:00
// @flow
import React from 'react';
import RewardLink from 'component/rewardLink';
2019-02-04 18:45:30 +01:00
import Icon from 'component/common/icon';
import * as ICONS from 'constants/icons';
2020-09-11 22:46:15 +02:00
import Card from 'component/common/card';
import LbcMessage from 'component/common/lbc-message';
2017-08-18 05:31:44 +02:00
2018-09-24 05:44:42 +02:00
type Props = {
invitees: ?Array<{
email: string,
invite_accepted: boolean,
invite_reward_claimed: boolean,
invite_reward_claimable: boolean,
}>,
2019-02-04 18:45:30 +01:00
referralReward: ?Reward,
2018-09-24 05:44:42 +02:00
};
class InviteList extends React.PureComponent<Props> {
2017-08-18 05:31:44 +02:00
render() {
2019-02-04 18:45:30 +01:00
const { invitees, referralReward } = this.props;
2017-08-18 05:31:44 +02:00
2019-09-26 18:07:11 +02:00
if (!invitees || !invitees.length) {
2017-08-18 05:31:44 +02:00
return null;
}
2019-02-04 18:45:30 +01:00
let rewardAmount = 0;
let rewardHelp = __(
2020-01-16 21:11:16 +01:00
"Woah, you have a lot of friends! You've claimed the maximum amount of invite rewards. Email %email% if you'd like to be whitelisted for more invites.",
{ email: 'hello@lbry.com' }
2019-02-04 18:45:30 +01:00
);
if (referralReward) {
rewardAmount = referralReward.reward_amount;
rewardHelp = referralReward.reward_description;
2019-02-04 18:45:30 +01:00
}
2019-05-07 23:38:29 +02:00
const showClaimable = invitees.some(invite => invite.invite_reward_claimable && !invite.invite_reward_claimed);
2019-02-04 18:45:30 +01:00
2017-08-18 05:31:44 +02:00
return (
2020-09-11 22:46:15 +02:00
<Card
title={<div className="table__header-text">{__('Invite History')}</div>}
subtitle={
<div className="table__header-text">
<LbcMessage>{rewardHelp}</LbcMessage>
</div>
}
2020-09-11 22:46:15 +02:00
titleActions={
referralReward &&
showClaimable && (
<div className="card__actions--inline">
2019-03-05 05:46:57 +01:00
<RewardLink
button
2020-10-08 19:15:22 +02:00
label={__(`Claim Your %reward_amount% Credit Invite Reward`, { reward_amount: rewardAmount })}
2020-04-02 21:09:35 +02:00
claim_code={referralReward.claim_code}
2019-03-05 05:46:57 +01:00
/>
2020-09-11 22:46:15 +02:00
</div>
)
}
isBodyList
body={
<div className="table__wrapper">
<table className="table section">
<thead>
<tr>
<th>{__('Invitee Email')}</th>
<th>{__('Invite Status')}</th>
<th>{__('Reward')}</th>
2019-12-18 06:27:08 +01:00
</tr>
2020-09-11 22:46:15 +02:00
</thead>
<tbody>
{invitees.map(invitee => (
<tr key={invitee.email}>
<td>{invitee.email}</td>
<td>
<span>{invitee.invite_accepted ? __('Accepted') : __('Not Accepted')}</span>
</td>
<td>
{invitee.invite_reward_claimed && (
<React.Fragment>
<span>{__('Claimed')}</span>
<Icon icon={ICONS.COMPLETE} />
</React.Fragment>
)}
{!invitee.invite_reward_claimed &&
(invitee.invite_reward_claimable ? <span>{__('Claimable')}</span> : __('Unclaimable'))}
</td>
</tr>
))}
</tbody>
</table>
</div>
}
/>
2017-08-18 05:31:44 +02:00
);
}
}
export default InviteList;