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' ;
2020-09-11 22:46:15 +02:00
import Card from 'component/common/card' ;
2020-09-15 21:46:36 +02:00
import LbcMessage from 'component/common/lbc-message' ;
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 ;
2020-09-15 21:46:36 +02:00
rewardHelp = referralReward . reward _description ;
2019-02-04 18:45:30 +01:00
}
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 (
2020-09-11 22:46:15 +02:00
< Card
title = { < div className = "table__header-text" > { _ _ ( 'Invite History' ) } < / div > }
2020-09-15 21:46:36 +02:00
subtitle = {
< div className = "table__header-text" >
< LbcMessage > { rewardHelp } < / LbcMessage >
< / div >
}
2020-09-11 22:46:15 +02:00
titleActions = {
referralReward &&
showClaimable && (
< div className = "card__actions--inline" >
2019-03-05 05:46:57 +01:00
< RewardLink
button
2020-10-08 19:15:22 +02:00
label = { _ _ ( ` Claim Your %reward_amount% Credit Invite Reward ` , { reward _amount : rewardAmount } ) }
2020-04-02 21:09:35 +02:00
claim _code = { referralReward . claim _code }
2019-03-05 05:46:57 +01:00
/ >
2020-09-11 22:46:15 +02:00
< / div >
)
}
isBodyList
body = {
< div className = "table__wrapper" >
< table className = "table section" >
< thead >
< tr >
< th > { _ _ ( 'Invitee Email' ) } < / th >
< th > { _ _ ( 'Invite Status' ) } < / th >
< th > { _ _ ( 'Reward' ) } < / th >
2019-12-18 06:27:08 +01:00
< / tr >
2020-09-11 22:46:15 +02: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
) ;
}
}
export default InviteList ;