forked from avral/golos-ui
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb62cf3
commit db95e80
Showing
10 changed files
with
279 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import React from 'react' | ||
import { Link } from 'react-router' | ||
import { connect } from 'react-redux' | ||
import tt from 'counterpart' | ||
import { Asset } from 'golos-lib-js/lib/utils' | ||
import CopyToClipboard from 'react-copy-to-clipboard' | ||
|
||
import DateJoinWrapper from 'app/components/elements/DateJoinWrapper' | ||
import Icon from 'app/components/elements/Icon' | ||
import LoadingIndicator from 'app/components/elements/LoadingIndicator' | ||
import TimeAgoWrapper from 'app/components/elements/TimeAgoWrapper' | ||
import LinkEx from 'app/utils/LinkEx' | ||
import { getLastSeen } from 'app/utils/NormalizeProfile' | ||
import { vestsToSteem } from 'app/utils/StateFunctions' | ||
|
||
class Referrals extends React.Component { | ||
constructor(props) { | ||
super(props) | ||
} | ||
|
||
state = { | ||
} | ||
|
||
render() { | ||
const { referrals, account } = this.props | ||
|
||
const props = this.props.props.toJS() | ||
|
||
if (!referrals || !referrals.get('loaded')){ | ||
return <div style={{ paddingBottom: '1rem' }}> | ||
<h3>{tt('referrals_jsx.title')}</h3> | ||
<LoadingIndicator type='circle' /> | ||
</div> | ||
} | ||
|
||
const refs = referrals.get('data').toJS() | ||
|
||
let count = 0 | ||
|
||
let items = refs.map(ref => { | ||
++count | ||
|
||
const { accounts } = this.props | ||
const acc = accounts.toJS()[ref.account] | ||
let lastSeen | ||
if (acc) { | ||
lastSeen = getLastSeen(acc) | ||
} | ||
|
||
const golosRewards = Asset(ref.referrer_rewards).plus(Asset(ref.referrer_donate_rewards)) | ||
|
||
return <tr key={ref.account} className={count % 2 == 0 ? '' : 'zebra'}> | ||
<td> | ||
<LinkEx to={'/@' + ref.account}><b> | ||
{ref.account} | ||
</b></LinkEx> | ||
</td> | ||
{acc && <td title={tt('referrals_jsx.vs')}> | ||
{vestsToSteem(acc.vesting_shares, props) + ' GOLOS'} | ||
</td>} | ||
{acc && <td title={tt('referrals_jsx.posts')}> | ||
{tt('user_profile.post_count', {count: acc.post_count || 0})} | ||
</td>} | ||
<td> | ||
<span title={tt('referrals_jsx.rewards')}> | ||
{' +'} | ||
{golosRewards.floatString} | ||
</span> | ||
{ref.referrer_donate_rewards_uia ? <span title={tt('referrals_jsx.donates_uia')}> | ||
{' + ' + ref.referrer_donate_rewards_uia + ' UIA'}</span> : null} | ||
</td> | ||
<td title={tt('referrals_jsx.joined')}> | ||
<DateJoinWrapper date={ref.joined} /> | ||
</td> | ||
<td title={tt('referrals_jsx.last')}> | ||
{lastSeen && <TimeAgoWrapper date={`${lastSeen}`} />} | ||
</td> | ||
</tr> | ||
}) | ||
|
||
let refUrl | ||
if (account) { | ||
refUrl = 'https://' + $STM_Config.site_domain + '/welcome?invite=' + account.name | ||
} | ||
|
||
return <div style={{ paddingBottom: '1rem' }}> | ||
<h3 style={{ display: 'inline-block' }}>{tt('referrals_jsx.title')}</h3> | ||
{refUrl && <span style={{float: 'right', fontSize: '85%'}} title={tt('g.referral_link_title')}> | ||
<Icon name="hf/hf5" size="2x" /> | ||
{' '}{tt('g.referral_link')}{' - '} | ||
<span style={{border: '1px solid lightgray', padding: '5px', borderRadius: '3px'}}> | ||
<a target="_blank" href={refUrl}>{refUrl}</a> | ||
</span> | ||
<CopyToClipboard text={refUrl}> | ||
<span style={{cursor: 'pointer'}}> | ||
<Icon name="copy" size="2x" /> | ||
</span> | ||
</CopyToClipboard> | ||
</span>} | ||
<div>{tt('referrals_jsx.desc')}</div> | ||
<table style={{marginTop: '1rem'}}> | ||
<thead> | ||
<th>{tt('referrals_jsx.name')}</th> | ||
<th>{tt('referrals_jsx.vs')}</th> | ||
<th>{tt('referrals_jsx.posts')}</th> | ||
<th>{tt('referrals_jsx.rewards')}</th> | ||
<th>{tt('referrals_jsx.joined')}</th> | ||
<th>{tt('referrals_jsx.last')}</th> | ||
</thead> | ||
<tbody> | ||
{items} | ||
</tbody></table> | ||
</div> | ||
} | ||
} | ||
|
||
|
||
export default connect( | ||
state => { | ||
const referrals = state.global.get('referrals') | ||
const accounts = state.global.get('accounts') | ||
const props = state.global.get('props') | ||
|
||
return { | ||
referrals, | ||
accounts, | ||
props | ||
} | ||
}, | ||
dispatch => ({ | ||
}) | ||
)(Referrals) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.