import {Link} from "react-router-dom"; import Button from '@material-ui/core/Button'; import React, {Component} from 'react'; import Typography from '@material-ui/core/Typography' import Card from '@material-ui/core/Card'; import CardContent from '@material-ui/core/CardContent'; import { withRouter } from 'react-router-dom' class VotingCredits extends Component { componentDidMount(){ const {polls, balances, history} = this.props; if(!polls || !balances || !polls.length || !balances.length){ history.push('/'); } } render(){ const {polls, balances, history} = this.props; if(!polls || !balances) return null; let title = polls[0].content.title; let description = polls[0].content.description; let ethBalance = web3.utils.fromWei(balances[0].ethBalance, "ether"); let tokenBalance = Math.floor(web3.utils.fromWei(balances[0].tokenBalance, "ether")); return (polls ?
{title} Voting Credits {tokenBalance} { tokenBalance > 0 && You get one credit for each SNT held in your wallet at the time of poll was created. They are usable only in this poll. } { tokenBalance == 0 &&
No SNT in your wallet To vote, you need to connect with a wallet that holds SNT tokens. Connect with another wallet
}
{ ethBalance == 0 && ETH {ethBalance} Not enough ETH in your wallet You will sign a transaction to confirm your vote. No tokens are sent, but you need ETH to pay for gas (Ethereum network fee). } { ethBalance == 0 || tokenBalance == 0 && } { ethBalance > 0 && tokenBalance > 0 && }
: null); } } export default withRouter(VotingCredits);