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';
|
2018-07-18 01:26:03 +02:00
|
|
|
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,
|
2018-07-18 01:26:03 +02:00
|
|
|
fetching: boolean,
|
|
|
|
fetchRewards: () => void,
|
2018-08-28 22:46:50 +02:00
|
|
|
fetchRewardedContent: () => void,
|
2017-12-12 21:49:50 +01:00
|
|
|
};
|
2017-12-12 00:50:22 +01:00
|
|
|
|
2018-07-18 01:26:03 +02:00
|
|
|
class RewardSummary extends React.Component<Props> {
|
|
|
|
componentDidMount() {
|
|
|
|
this.props.fetchRewards();
|
2018-08-28 22:46:50 +02:00
|
|
|
this.props.fetchRewardedContent();
|
2018-07-18 01:26:03 +02:00
|
|
|
}
|
2017-08-20 23:42:00 +02:00
|
|
|
|
2018-07-18 01:26:03 +02:00
|
|
|
render() {
|
|
|
|
const { unclaimedRewardAmount, fetching } = this.props;
|
|
|
|
const hasRewards = unclaimedRewardAmount > 0;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<section className="card card--section">
|
2018-12-19 06:44:53 +01:00
|
|
|
<header className="card__header">
|
|
|
|
<h2 className="card__title">
|
|
|
|
{__('Rewards')}
|
|
|
|
{fetching && <BusyIndicator />}
|
|
|
|
</h2>
|
|
|
|
|
|
|
|
<p className="card__subtitle">
|
|
|
|
{!fetching &&
|
|
|
|
(hasRewards ? (
|
|
|
|
<React.Fragment>
|
|
|
|
{__('You have')}
|
|
|
|
|
|
|
|
<CreditAmount inheritStyle amount={unclaimedRewardAmount} precision={8} />
|
|
|
|
|
|
|
|
{__('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" />.
|
2018-12-19 06:44:53 +01:00
|
|
|
</p>
|
|
|
|
</header>
|
|
|
|
|
|
|
|
<div className="card__content">
|
|
|
|
<div className="card__actions">
|
|
|
|
<Button
|
|
|
|
button="primary"
|
2019-03-28 17:53:13 +01:00
|
|
|
navigate="/$/rewards"
|
2018-12-19 06:44:53 +01:00
|
|
|
label={hasRewards ? __('Claim Rewards') : __('View Rewards')}
|
|
|
|
/>
|
|
|
|
</div>
|
2018-07-18 01:26:03 +02:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2017-08-20 23:42:00 +02:00
|
|
|
|
|
|
|
export default RewardSummary;
|