Skip to content

Commit

Permalink
Merge b75e240 into 86f1c5f
Browse files Browse the repository at this point in the history
  • Loading branch information
Agupane committed Jan 15, 2019
2 parents 86f1c5f + b75e240 commit 2c00619
Show file tree
Hide file tree
Showing 8 changed files with 252 additions and 156 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
NODE_ENV=development
REACT_APP_API_BASE_URL=http://localhost:4040/api/subscribers/
REACT_LIVEPEER_TELEGRAM_BOT_URL=https://t.me/LivepeerNotificationBot
REACT_APP_LIVEPEER_TELEGRAM_BOT_URL=https://t.me/LivepeerNotificationBot
208 changes: 104 additions & 104 deletions package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ import { withStyles } from '@material-ui/core/styles'

const accountSummarySubscriptionFormDisplay = props => {
const { classes } = props

return (
<GridContainer className={classes.gridContainer} justify="center" alignItems="center">
<GridItem className={classes.cardContainer}>
<Card className={classes.cardSignup}>
<h2 className={classes.cardTitle}>Subscribe:</h2>
<form onSubmit={props.onSubmitBtnHandler}>
<form>
<Input
changed={event => props.inputChangedHandler(event, 'email')}
elementConfig={props.form.email.elementConfig}
Expand All @@ -31,6 +30,7 @@ const accountSummarySubscriptionFormDisplay = props => {
disabled={!props.form.formIsValid}
round
size="lg"
onClick={props.onSubmitBtnHandler}
>
Subscribe
</Button>
Expand Down
7 changes: 4 additions & 3 deletions src/Components/AccountSummary/AccountSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export class AccountSummaryComponent extends Component {
startRound: '',
status: 'Bonded',
withdrawRound: '',
stake: ''
stake: '',
delegateCalledReward: false
},
render: false,
displayMsg: displayTexts.LOADING_USER_DATA,
Expand Down Expand Up @@ -184,7 +185,8 @@ export class AccountSummaryComponent extends Component {
startRound: summaryData.data.summary.startRound,
status: summaryData.data.summary.status,
stake: summaryData.data.summary.totalStake,
withdrawRound: summaryData.data.summary.withdrawRound
withdrawRound: summaryData.data.summary.withdrawRound,
delegateCalledReward: summaryData.data.summary.delegatedCalledReward
},
lpBalance: summaryData.data.balance
},
Expand Down Expand Up @@ -225,7 +227,6 @@ export class AccountSummaryComponent extends Component {
}

onSubscribeBtnHandler = async () => {
logger.log('Subscribe btnHandler')
this.props.history.push('/account/subscription')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const AccountSummaryData = props => {
},
{
title: 'Status',
data: props.summary.status + ', ' + statusMsg
data: statusMsg
},
{
title: 'Stake',
Expand Down Expand Up @@ -61,46 +61,77 @@ const AccountSummaryData = props => {

const getStatusMsg = props => {
let msg
const { classes } = props
switch (props.summary && props.summary.status) {
case 'Pending': {
msg = (
<td>
your LPT is getting deluded by the protocol's token inflation. Add value to the network,
bond to a transcoder here.
</td>
<>
<p className={classes.textLeft}>{props.summary.status}</p>
<p className={classes.textLeft}>
your LPT is getting deluded by the protocol's token inflation.
</p>
<p className={classes.textLeft}>
Add value to the network, bond to a transcoder
<a href="https://explorer.livepeer.org/transcoders"> here</a>
</p>
</>
)
msg =
" your LPT is getting deluded by the protocol's token inflation. Add value to the network,\n" +
' bond to a transcoder here.'
break
}
case 'Bonded': {
let tokenRewardsText
const delegateAddress = props.summary.delegateAddress
const delegateAddressUrl = 'https://explorer.livepeer.org/accounts/' + delegateAddress

if (!props.summary.delegateCalledReward) {
tokenRewardsText = (
<p className={classes.textLeft}>
Unfortunately the transcoder has not claimed the last inflationary token rewards.
</p>
)
} else {
tokenRewardsText = (
<p className={classes.textLeft}>
The transcoder has successfully claimed the last inflationary token rewards.
</p>
)
}
msg = (
<td>
bonded to transcoder {props.summary.delegateAddress} at round {props.summary.startRound}
</td>
<>
<p className={classes.textLeft}>{props.summary.status} </p>
<p className={classes.textLeft}>
bonded to transcoder <a href={delegateAddressUrl}>{delegateAddress}</a> at round{' '}
{props.summary.startRound}{' '}
</p>
{tokenRewardsText}
</>
)
msg =
'bonded to transcoder ' +
props.summary.delegateAddress +
'at round {props.summary.startRound}'
break
}
case 'Unbonding': {
msg = <td>your still have to wait a few moments to get finally unbonded.</td>
msg = 'your still have to wait a few moments to get finally unbonded.'
msg = (
<>
<p className={classes.textLeft}>{props.summary.status}</p>
<p className={classes.textLeft}>
your still have to wait a few moments to get finally unbonded.
</p>
</>
)
break
}
case 'Unbonded': {
msg = (
<td>
your LPT is getting deluded by the protocol's token inflation. Add value to the network,
bond to a transcoder here.
</td>
<>
<p className={classes.textLeft}>{props.summary.status}</p>
<p className={classes.textLeft}>
your LPT is getting deluded by the protocol's token inflation.
</p>
<p className={classes.textLeft}>
Add value to the network, bond to a transcoder
<a href="https://explorer.livepeer.org/transcoders"> here</a>
</p>
</>
)
msg =
"your LPT is getting deluded by the protocol's token inflation. Add value to the network,\n" +
' bond to a transcoder here.'
break
}
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,12 @@ const AccountSummaryHome = props => {
}

const address = props.userData && props.userData.address
const telegramLink = `${process.env.LIVEPEER_TELEGRAM_BOT_URL}?start=${address}`
const telegramLink = `${process.env.REACT_APP_LIVEPEER_TELEGRAM_BOT_URL}?start=${address}`
const openTelegramLink = () => {
window.open(telegramLink, '_blank')
}

const summaryTitle = `Welcome ${truncateStringInTheMiddle(address)}`

return (
<GridContainer className={classes.gridContainer} justify="center">
<GridItem className={classes.cardContainer}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ const AccountSummaryStyle = {
textRight: {
textAlign: 'right'
},
textLeft: {
textAlign: 'left'
},
wordBreak: {
wordBreak: 'break-all'
},
Expand Down
102 changes: 82 additions & 20 deletions src/Tests/AccountSummary/AccountSummaryData.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ configure({ adapter: new Adapter() })

const props = {
summary: {
bondedAmount: 0,
fees: 0,
status: 'Bounded',
lastClaimRound: 0,
startRound: 0,
withdrawRound: 0
bondedAmount: '',
delegateAddress: '',
delegatedAmount: '',
fees: '',
lastClaimRound: '',
startRound: '',
status: 'Bonded',
withdrawRound: '',
stake: '',
delegateCalledReward: false
}
}

Expand All @@ -35,24 +39,82 @@ describe('Renders account summary data', () => {
let tr = wrapper.find('TableCell').map(tr => tr.text())
expect(tr[5] === message).toEqual(true)
})
/*
it('Shows LastClaimRound', () => {
const message = 'LastClaimRound'
let wrapper = mount(<AccountSummaryData {...props} />)

it('Shows Bonded status msg if status is bonded and delegatedHasNotCalledReward', () => {
const messageStatus = 'bonded to transcoder 1234 at round 1'
const messageReward =
'Unfortunately the transcoder has not claimed the last inflationary token rewards.'
const propsStatus = {
summary: {
delegateAddress: '1234',
startRound: '1',
status: 'Bonded',
delegateCalledReward: false
}
}
let wrapper = mount(<AccountSummaryData {...propsStatus} />)
let tr = wrapper.find('TableCell').map(tr => tr.text())
expect(tr[7] === message).toEqual(true)
expect(tr[6].includes(messageStatus)).toEqual(true)
expect(tr[6].includes(messageReward)).toEqual(true)
})
it('Shows StartRound', () => {
const message = 'StartRound'
let wrapper = mount(<AccountSummaryData {...props} />)
it('Shows Bonded status msg if status is bonded and delegatedHasCalledReward', () => {
const messageStatus = 'bonded to transcoder 1234 at round 1'
const messageReward =
'The transcoder has successfully claimed the last inflationary token rewards.'
const propsStatus = {
summary: {
delegateAddress: '1234',
startRound: '1',
status: 'Bonded',
delegateCalledReward: true
}
}
let wrapper = mount(<AccountSummaryData {...propsStatus} />)
let tr = wrapper.find('TableCell').map(tr => tr.text())
expect(tr[9] === message).toEqual(true)
expect(tr[6].includes(messageStatus)).toEqual(true)
expect(tr[6].includes(messageReward)).toEqual(true)
})
it('Shows WithdrawRound', () => {
const message = 'WithdrawRound'
let wrapper = mount(<AccountSummaryData {...props} />)
it('Shows pending msg if status is pending', () => {
const messageStatus = 'Pending'
const messageExtra = "your LPT is getting deluded by the protocol's token inflation."
const msgAddValue = 'Add value to the network, bond to a transcoder here'
const propsStatus = {
summary: {
status: 'Pending'
}
}
let wrapper = mount(<AccountSummaryData {...propsStatus} />)
let tr = wrapper.find('TableCell').map(tr => tr.text())
expect(tr[6].includes(messageStatus)).toEqual(true)
expect(tr[6].includes(messageExtra)).toEqual(true)
expect(tr[6].includes(msgAddValue)).toEqual(true)
})
it('Shows Unbonded msg if status is Unbonded', () => {
const messageStatus = 'Unbonded'
const messageExtra = "your LPT is getting deluded by the protocol's token inflation."
const msgAddValue = 'Add value to the network, bond to a transcoder here'
const propsStatus = {
summary: {
status: 'Unbonded'
}
}
let wrapper = mount(<AccountSummaryData {...propsStatus} />)
let tr = wrapper.find('TableCell').map(tr => tr.text())
expect(tr[6].includes(messageStatus)).toEqual(true)
expect(tr[6].includes(messageExtra)).toEqual(true)
expect(tr[6].includes(msgAddValue)).toEqual(true)
})
it('Shows Unbonding msg if status is Unbonding', () => {
const messageStatus = 'Unbonding'
const messageExtra = 'your still have to wait a few moments to get finally unbonded.'
const propsStatus = {
summary: {
status: 'Unbonding'
}
}
let wrapper = mount(<AccountSummaryData {...propsStatus} />)
let tr = wrapper.find('TableCell').map(tr => tr.text())
expect(tr[11] === message).toEqual(true)
expect(tr[6].includes(messageStatus)).toEqual(true)
expect(tr[6].includes(messageExtra)).toEqual(true)
})
*/
})

0 comments on commit 2c00619

Please sign in to comment.