2018-03-26 23:32:43 +02:00
|
|
|
// @flow
|
2018-11-26 02:21:25 +01:00
|
|
|
import * as ICONS from 'constants/icons';
|
2017-12-21 22:08:54 +01:00
|
|
|
import React from 'react';
|
2018-03-26 23:32:43 +02:00
|
|
|
import Icon from 'component/common/icon';
|
2017-12-21 22:08:54 +01:00
|
|
|
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';
|
2017-08-19 05:08:01 +02:00
|
|
|
|
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,
|
2019-09-04 23:37:28 +02:00
|
|
|
reward_range?: string,
|
2018-03-26 23:32:43 +02:00
|
|
|
transaction_id: string,
|
|
|
|
created_at: string,
|
|
|
|
reward_description: string,
|
|
|
|
reward_type: string,
|
|
|
|
},
|
|
|
|
};
|
2017-08-19 05:08:01 +02:00
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
const RewardTile = (props: Props) => {
|
2018-09-26 02:12:07 +02:00
|
|
|
const { reward, openRewardCodeModal } = props;
|
2017-08-19 05:08:01 +02:00
|
|
|
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>
|
|
|
|
}
|
|
|
|
/>
|
2017-08-19 05:08:01 +02:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default RewardTile;
|