import {Link} from "react-router-dom"; import Button from '@material-ui/core/Button'; import React, {Component, Fragment} 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' import HelpDialog from './HelpDialog'; Date.prototype.DDMMYYYY = function () { var yyyy = this.getFullYear().toString(); var MM = pad(this.getMonth() + 1,2); var dd = pad(this.getDate(), 2); return dd + '/' + MM + '/' + yyyy ; }; function pad(number, length) { var str = '' + number; while (str.length < length) { str = '0' + str; } return str; } class VotingCredits extends Component { state = { open: false, }; handleClickOpen = () => { this.setState({ open: true }); }; handleClose = () => { this.setState({ open: false }); }; componentDidMount(){ const {polls, balances, history} = this.props; if(!polls || !balances || !polls.length || !balances.length){ history.push('/'); } } render(){ const {polls, balances, idPoll} = this.props; if(!polls || !balances) return null; const poll = polls[polls.length - 1]; let title = poll.content.title; let description = poll.content.description; let ethBalance = web3.utils.fromWei(balances[idPoll].ethBalance, "ether"); let tokenBalance = Math.floor(web3.utils.fromWei(balances[idPoll].tokenBalance, "ether")); const d = new Date(poll.blockInfo.timestamp * 1000); 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 ({d.DDMMYYYY()}). 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 when the poll was created ({d.DDMMYYYY()}).
}
{ 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).
}

Need help? Chat with us

{ (ethBalance == 0 || tokenBalance == 0) && } { (ethBalance > 0 && tokenBalance > 0) && }
: null); } } export default withRouter(VotingCredits);