2018-09-24 05:44:42 +02:00
// @flow
2017-12-21 22:08:54 +01:00
import React from 'react' ;
import RewardLink from 'component/rewardLink' ;
2019-02-04 18:45:30 +01:00
import Icon from 'component/common/icon' ;
import * as ICONS from 'constants/icons' ;
2017-08-18 05:31:44 +02:00
2018-09-24 05:44:42 +02:00
type Props = {
invitees : ? Array < {
email : string ,
invite _accepted : boolean ,
invite _reward _claimed : boolean ,
invite _reward _claimable : boolean ,
} > ,
2019-02-04 18:45:30 +01:00
referralReward : ? Reward ,
2018-09-24 05:44:42 +02:00
} ;
class InviteList extends React . PureComponent < Props > {
2017-08-18 05:31:44 +02:00
render ( ) {
2019-02-04 18:45:30 +01:00
const { invitees , referralReward } = this . props ;
2017-08-18 05:31:44 +02:00
2019-09-26 18:07:11 +02:00
if ( ! invitees || ! invitees . length ) {
2017-08-18 05:31:44 +02:00
return null ;
}
2019-02-04 18:45:30 +01:00
let rewardAmount = 0 ;
let rewardHelp = _ _ (
2020-01-16 21:11:16 +01:00
"Woah, you have a lot of friends! You've claimed the maximum amount of invite rewards. Email %email% if you'd like to be whitelisted for more invites." ,
{ email : 'hello@lbry.com' }
2019-02-04 18:45:30 +01:00
) ;
if ( referralReward ) {
rewardAmount = referralReward . reward _amount ;
rewardHelp = referralReward . reward _description ;
}
2019-05-07 23:38:29 +02:00
const showClaimable = invitees . some ( invite => invite . invite _reward _claimable && ! invite . invite _reward _claimed ) ;
2019-02-04 18:45:30 +01:00
2017-08-18 05:31:44 +02:00
return (
2019-07-21 23:31:22 +02:00
< section className = "card" >
< div className = "table__header" >
2019-11-22 22:13:00 +01:00
< div className = "table__header-text--between" >
< div >
< h2 className = "card__title" > { _ _ ( 'Invite History' ) } < / h2 >
< p className = "section__subtitle" > { rewardHelp } < / p >
< / div >
2019-03-05 05:46:57 +01:00
{ referralReward && showClaimable && (
< RewardLink
button
2020-09-02 22:08:37 +02:00
label = { _ _ ( ` Claim Your ${ rewardAmount } Credit Invite Reward ` ) }
2020-04-02 21:09:35 +02:00
claim _code = { referralReward . claim _code }
2019-03-05 05:46:57 +01:00
/ >
) }
2019-11-22 22:13:00 +01:00
< / div >
2019-07-21 23:31:22 +02:00
< / div >
2019-02-04 18:45:30 +01:00
2019-12-18 06:27:08 +01:00
< div className = "table__wrapper" >
< table className = "table section" >
< thead >
< tr >
< th > { _ _ ( 'Invitee Email' ) } < / th >
< th > { _ _ ( 'Invite Status' ) } < / th >
< th > { _ _ ( 'Reward' ) } < / th >
2019-07-21 23:31:22 +02:00
< / tr >
2019-12-18 06:27:08 +01:00
< / thead >
< tbody >
{ invitees . map ( invitee => (
< tr key = { invitee . email } >
< td > { invitee . email } < / td >
< td >
< span > { invitee . invite _accepted ? _ _ ( 'Accepted' ) : _ _ ( 'Not Accepted' ) } < / span >
< / td >
< td >
{ invitee . invite _reward _claimed && (
< React.Fragment >
< span > { _ _ ( 'Claimed' ) } < / span >
< Icon icon = { ICONS . COMPLETE } / >
< / React.Fragment >
) }
{ ! invitee . invite _reward _claimed &&
( invitee . invite _reward _claimable ? < span > { _ _ ( 'Claimable' ) } < / span > : _ _ ( 'Unclaimable' ) ) }
< / td >
< / tr >
) ) }
< / tbody >
< / table >
< / div >
2017-08-18 05:31:44 +02:00
< / section >
) ;
}
}
export default InviteList ;