2018-06-27 18:40:45 +00:00
|
|
|
import React, { Fragment, PureComponent } from 'react';
|
2018-06-27 16:32:11 +00:00
|
|
|
import Card from '@material-ui/core/Card';
|
|
|
|
import CardContent from '@material-ui/core/CardContent';
|
2018-06-27 18:40:45 +00:00
|
|
|
import CardActions from '@material-ui/core/CardActions';
|
2018-06-27 16:32:11 +00:00
|
|
|
import Button from '@material-ui/core/Button';
|
|
|
|
import Typography from '@material-ui/core/Typography';
|
2018-06-27 18:40:45 +00:00
|
|
|
import Slider from '@material-ui/lab/Slider';
|
|
|
|
import Tooltip from '@material-ui/core/Tooltip';
|
2018-06-27 16:32:11 +00:00
|
|
|
|
2018-06-27 18:40:45 +00:00
|
|
|
class Poll extends PureComponent {
|
|
|
|
state = {
|
|
|
|
value: 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
handleChange = (event, value) => {
|
|
|
|
this.setState({ value });
|
|
|
|
};
|
|
|
|
|
|
|
|
render(){
|
|
|
|
const { _question, _totalCensus, _voters } = this.props;
|
|
|
|
const { value } = this.state;
|
|
|
|
return (
|
|
|
|
<Card>
|
|
|
|
<CardContent>
|
|
|
|
<Typography variant="headline">Proposal: {_question}</Typography>
|
|
|
|
<Typography variant="subheading" color="textSecondary">
|
|
|
|
Total SNT Voted: {_totalCensus}
|
|
|
|
</Typography>
|
|
|
|
<Typography variant="subheading" color="textSecondary">
|
|
|
|
Number of voters: {_voters}
|
|
|
|
</Typography>
|
|
|
|
</CardContent>
|
2018-06-27 19:50:08 +00:00
|
|
|
<Tooltip id="tooltip-icon" placement="top" title={`${value * value} SNT`}>
|
2018-06-27 18:40:45 +00:00
|
|
|
<CardActions>
|
|
|
|
<Slider value={value} min={0} max={6} step={1} onChange={this.handleChange} />
|
|
|
|
<Button variant="contained" color="primary">Vote</Button>
|
|
|
|
</CardActions>
|
|
|
|
</Tooltip>
|
|
|
|
</Card>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2018-06-27 16:32:11 +00:00
|
|
|
|
|
|
|
const PollsList = ({ rawPolls }) => (
|
|
|
|
<Fragment>
|
2018-06-27 17:54:36 +00:00
|
|
|
{rawPolls.map((poll, idx) => <Poll key={idx} {...poll} />)}
|
2018-06-27 16:32:11 +00:00
|
|
|
</Fragment>
|
|
|
|
)
|
|
|
|
|
|
|
|
export default PollsList
|