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

55 lines
1.5 KiB
React
Raw Normal View History

2018-03-26 23:32:43 +02:00
// @flow
2018-11-26 02:21:25 +01:00
import * as ICONS from 'constants/icons';
import React from 'react';
2018-03-26 23:32:43 +02:00
import Icon from 'component/common/icon';
import RewardLink from 'component/rewardLink';
2018-03-26 23:32:43 +02:00
import Button from 'component/button';
2019-09-26 18:07:11 +02:00
import Card from 'component/common/card';
2018-09-24 05:44:42 +02:00
import { rewards } from 'lbryinc';
2018-03-26 23:32:43 +02:00
type Props = {
2018-09-26 02:12:07 +02:00
openRewardCodeModal: () => void,
2018-03-26 23:32:43 +02:00
reward: {
id: string,
reward_title: string,
reward_amount: number,
reward_range?: string,
2018-03-26 23:32:43 +02:00
transaction_id: string,
created_at: string,
reward_description: string,
reward_type: string,
},
};
2018-03-26 23:32:43 +02:00
const RewardTile = (props: Props) => {
2018-09-26 02:12:07 +02:00
const { reward, openRewardCodeModal } = props;
const claimed = !!reward.transaction_id;
return (
2019-09-26 18:07:11 +02:00
<Card
title={reward.reward_title}
subtitle={reward.reward_description}
actions={
<div className="card__actions">
{reward.reward_type === rewards.TYPE_GENERATED_CODE && (
<Button button="primary" onClick={openRewardCodeModal} label={__('Enter Code')} />
)}
{reward.reward_type === rewards.TYPE_REFERRAL && (
<Button button="primary" navigate="/$/invite" label={__('Go To Invites')} />
)}
{reward.reward_type !== rewards.TYPE_REFERRAL &&
(claimed ? (
<span>
<Icon icon={ICONS.COMPLETED} /> {__('Reward claimed.')}
</span>
) : (
<RewardLink button reward_type={reward.reward_type} />
))}
</div>
}
/>
);
};
export default RewardTile;