lbry-desktop/src/ui/component/rewardSummary/view.jsx

66 lines
1.9 KiB
React
Raw Normal View History

2017-12-12 00:50:22 +01:00
// @flow
2018-03-26 23:32:43 +02:00
import * as React from 'react';
import Button from 'component/button';
import CreditAmount from 'component/common/credit-amount';
import BusyIndicator from 'component/common/busy-indicator';
2017-08-20 23:42:00 +02:00
2017-12-12 00:50:22 +01:00
type Props = {
unclaimedRewardAmount: number,
fetching: boolean,
fetchRewards: () => void,
fetchRewardedContent: () => void,
2017-12-12 21:49:50 +01:00
};
2017-12-12 00:50:22 +01:00
class RewardSummary extends React.Component<Props> {
componentDidMount() {
this.props.fetchRewards();
this.props.fetchRewardedContent();
}
2017-08-20 23:42:00 +02:00
render() {
const { unclaimedRewardAmount, fetching } = this.props;
const hasRewards = unclaimedRewardAmount > 0;
return (
<section className="card card--section">
<header className="card__header">
<h2 className="card__title">
{__('Rewards')}
{fetching && <BusyIndicator />}
</h2>
<p className="card__subtitle">
{!fetching &&
(hasRewards ? (
<React.Fragment>
{__('You have')}
&nbsp;
<CreditAmount inheritStyle amount={unclaimedRewardAmount} precision={8} />
&nbsp;
{__('in unclaimed rewards')}.
</React.Fragment>
) : (
<React.Fragment>
{__('There are no rewards available at this time, please check back later')}.
</React.Fragment>
2019-06-11 20:10:58 +02:00
))}{' '}
<Button button="link" label={__('Learn more')} href="https://lbry.com/faq/rewards" />.
</p>
</header>
<div className="card__content">
<div className="card__actions">
<Button
button="primary"
2019-03-28 17:53:13 +01:00
navigate="/$/rewards"
label={hasRewards ? __('Claim Rewards') : __('View Rewards')}
/>
</div>
</div>
</section>
);
}
}
2017-08-20 23:42:00 +02:00
export default RewardSummary;