diff --git a/app/components/simple-voting/PollsList.js b/app/components/simple-voting/PollsList.js index 355c173..95217d6 100644 --- a/app/components/simple-voting/PollsList.js +++ b/app/components/simple-voting/PollsList.js @@ -5,7 +5,6 @@ import CardActions from '@material-ui/core/CardActions'; import Button from '@material-ui/core/Button'; import Typography from '@material-ui/core/Typography'; import Slider from '@material-ui/lab/Slider'; -import Tooltip from '@material-ui/core/Tooltip'; import PollManager from 'Embark/contracts/PollManager'; import MiniMeTokenInterface from 'Embark/contracts/MiniMeTokenInterface'; import web3 from "Embark/web3" @@ -83,7 +82,8 @@ class Poll extends Component { PollManager.methods.getVote(this.props.idPoll, web3.eth.defaultAccount) .call() .then(vote => { - this.setState({value: parseInt(Math.sqrt(fromWei(vote)))}); + const value = parseInt(Math.sqrt(fromWei(vote))); + this.setState({ value, originalValue: value }); }) } @@ -98,33 +98,28 @@ class Poll extends Component { balance, classes } = this.props; - const { value, isSubmitting } = this.state; + const { value, originalValue, isSubmitting } = this.state; //TODO if (isNil(value)) setState using pollmanager getvote const disableVote = balance == 0 || !_canVote || isSubmitting; const { fromWei } = web3.utils; const maxValue = Math.floor(Math.sqrt(balance)); - + const buttonText = originalValue != 0 && value != originalValue ? 'Change Vote' : 'Vote'; return ( {_description} - Number of voters: {_voters} + Total: {_voters} voters. {_qvResults} votes ({fromWei(_results)} SNT) - Votes: {_qvResults} - - - SNT Allocated: {fromWei(_results)} + Your vote: {value} votes ({value * value} SNT) - - - - {isSubmitting ? : } - - + + + {isSubmitting ? : } + ) } @@ -133,14 +128,14 @@ class Poll extends Component { const PollsList = ({ classes }) => ( - {({ updatePoll, rawPolls, pollOrder, appendToPoll }) => - - {rawPolls - .map((poll, i) => ({ ...poll, idPoll: i }) ) - .sort(sortingFn[pollOrder]) - .map((poll) => )} - - } + {({ updatePoll, rawPolls, pollOrder, appendToPoll }) => + + {rawPolls + .map((poll, i) => ({ ...poll, idPoll: i }) ) + .sort(sortingFn[pollOrder]) + .map((poll) => )} + + } )