2018-10-16 16:20:54 -04:00
|
|
|
import {Link} from "react-router-dom";
|
|
|
|
import Button from '@material-ui/core/Button';
|
|
|
|
import React, {Component} from 'react';
|
|
|
|
import Card from '@material-ui/core/Card';
|
|
|
|
import CardActions from '@material-ui/core/CardActions';
|
|
|
|
import CardContent from '@material-ui/core/CardContent';
|
|
|
|
import Typography from '@material-ui/core/Typography';
|
|
|
|
import DialogTitle from '@material-ui/core/DialogTitle';
|
|
|
|
import Dialog from '@material-ui/core/Dialog';
|
|
|
|
import DialogActions from '@material-ui/core/DialogActions';
|
|
|
|
import DialogContent from '@material-ui/core/DialogContent';
|
|
|
|
|
|
|
|
class LearnAboutBallots extends Component {
|
|
|
|
state = {
|
2018-10-16 18:52:40 -04:00
|
|
|
open: false,
|
|
|
|
dialogTitle: '',
|
|
|
|
dialogText: ''
|
2018-10-16 16:20:54 -04:00
|
|
|
};
|
|
|
|
|
2018-10-16 18:52:40 -04:00
|
|
|
handleClickOpen = (dialogTitle, dialogText) => {
|
2018-10-16 16:20:54 -04:00
|
|
|
this.setState({
|
2018-10-16 18:52:40 -04:00
|
|
|
open: true,
|
|
|
|
dialogTitle,
|
|
|
|
dialogText
|
2018-10-16 16:20:54 -04:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
handleClose = value => {
|
|
|
|
this.setState({ open: false });
|
|
|
|
};
|
|
|
|
|
|
|
|
render(){
|
2018-10-16 18:52:40 -04:00
|
|
|
const {polls} = this.props;
|
|
|
|
|
|
|
|
let title, ballots = [];
|
|
|
|
if(polls && polls.length){
|
|
|
|
title = polls[0].content.title;
|
|
|
|
ballots = polls[0].content.ballots;
|
|
|
|
}
|
|
|
|
|
2018-10-16 16:20:54 -04:00
|
|
|
return (
|
2018-10-16 18:52:40 -04:00
|
|
|
<div class="section">
|
|
|
|
<Typography variant="headline">{title}</Typography>
|
2018-10-16 16:20:54 -04:00
|
|
|
<BallotDialog
|
2018-10-16 18:52:40 -04:00
|
|
|
title={this.state.dialogTitle}
|
|
|
|
text={this.state.dialogText}
|
2018-10-16 16:20:54 -04:00
|
|
|
open={this.state.open}
|
|
|
|
onClose={this.handleClose}
|
|
|
|
/>
|
2018-10-16 18:52:40 -04:00
|
|
|
{
|
|
|
|
ballots.map((item, i) => {
|
|
|
|
return <Card key={i} className="card">
|
|
|
|
<CardContent>
|
|
|
|
<Typography gutterBottom component="h2">{item.title}</Typography>
|
|
|
|
<Typography component="p">{item.subtitle}</Typography>
|
|
|
|
</CardContent>
|
|
|
|
<CardActions>
|
|
|
|
<Button size="small" color="primary" onClick={() => this.handleClickOpen(item.title, item.content)}>Learn more ></Button>
|
|
|
|
</CardActions>
|
|
|
|
</Card>
|
|
|
|
})
|
|
|
|
}
|
2018-10-16 16:20:54 -04:00
|
|
|
<Link to="/votingHelp"> <Button>How voting works</Button></Link>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class BallotDialog extends Component {
|
|
|
|
|
|
|
|
handleClose = () => {
|
|
|
|
this.props.onClose(this.props.selectedValue);
|
|
|
|
};
|
|
|
|
|
|
|
|
handleListItemClick = value => {
|
|
|
|
this.props.onClose(value);
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
2018-10-16 18:52:40 -04:00
|
|
|
const { onClose, title, text, polls, ...other } = this.props;
|
|
|
|
|
2018-10-16 16:20:54 -04:00
|
|
|
return (
|
|
|
|
<Dialog onClose={this.handleClose} aria-labelledby="simple-dialog-title" {...other}>
|
2018-10-16 18:52:40 -04:00
|
|
|
<DialogTitle>{title}</DialogTitle>
|
2018-10-16 16:20:54 -04:00
|
|
|
<DialogContent>
|
2018-10-16 18:52:40 -04:00
|
|
|
<Typography variant="body1" component="div">{text}</Typography>
|
2018-10-16 16:20:54 -04:00
|
|
|
</DialogContent>
|
|
|
|
<DialogActions>
|
|
|
|
<Button onClick={this.handleClose} color="primary" autoFocus>Ok</Button>
|
|
|
|
</DialogActions>
|
|
|
|
</Dialog>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default LearnAboutBallots;
|