display poll in app
This commit is contained in:
parent
923ec77861
commit
46e57ae8e2
|
@ -74,9 +74,9 @@ class OrderingDialog extends PureComponent {
|
||||||
onClose={this.handleClose}
|
onClose={this.handleClose}
|
||||||
TransitionComponent={Transition}
|
TransitionComponent={Transition}
|
||||||
>
|
>
|
||||||
<AppBar className={classes.appBar}>
|
<AppBar className={classes.appBar} onClick={this.handleClose}>
|
||||||
<Toolbar>
|
<Toolbar>
|
||||||
<IconButton color="inherit" onClick={this.handleClose} aria-label="Close">
|
<IconButton color="inherit" aria-label="Close">
|
||||||
<CloseIcon />
|
<CloseIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<Typography variant="title" color="inherit" className={classes.flex}>
|
<Typography variant="title" color="inherit" className={classes.flex}>
|
||||||
|
|
|
@ -1,12 +1,19 @@
|
||||||
import React, { Fragment, PureComponent } from 'react';
|
import React, { Fragment, PureComponent } from 'react';
|
||||||
|
import AppBar from '@material-ui/core/AppBar';
|
||||||
|
import Toolbar from '@material-ui/core/Toolbar';
|
||||||
|
import Iframe from 'react-iframe';
|
||||||
import Card from '@material-ui/core/Card';
|
import Card from '@material-ui/core/Card';
|
||||||
import CardContent from '@material-ui/core/CardContent';
|
import CardContent from '@material-ui/core/CardContent';
|
||||||
import CardActions from '@material-ui/core/CardActions';
|
import CardActions from '@material-ui/core/CardActions';
|
||||||
import Button from '@material-ui/core/Button';
|
import Button from '@material-ui/core/Button';
|
||||||
|
import Dialog from '@material-ui/core/Dialog';
|
||||||
|
import Slide from '@material-ui/core/Slide';
|
||||||
import Typography from '@material-ui/core/Typography';
|
import Typography from '@material-ui/core/Typography';
|
||||||
import Slider from '@material-ui/lab/Slider';
|
import Slider from '@material-ui/lab/Slider';
|
||||||
import PollManager from 'Embark/contracts/PollManager';
|
import PollManager from 'Embark/contracts/PollManager';
|
||||||
import MiniMeTokenInterface from 'Embark/contracts/MiniMeTokenInterface';
|
import MiniMeTokenInterface from 'Embark/contracts/MiniMeTokenInterface';
|
||||||
|
import IconButton from '@material-ui/core/IconButton';
|
||||||
|
import CloseIcon from '@material-ui/icons/Close';
|
||||||
import web3 from "Embark/web3"
|
import web3 from "Embark/web3"
|
||||||
import CircularProgress from '@material-ui/core/CircularProgress';
|
import CircularProgress from '@material-ui/core/CircularProgress';
|
||||||
import { withStyles } from '@material-ui/core/styles';
|
import { withStyles } from '@material-ui/core/styles';
|
||||||
|
@ -21,7 +28,16 @@ const styles = {
|
||||||
thumb: {
|
thumb: {
|
||||||
width: '24px',
|
width: '24px',
|
||||||
height: '24px'
|
height: '24px'
|
||||||
}
|
},
|
||||||
|
appBar: {
|
||||||
|
position: 'relative',
|
||||||
|
},
|
||||||
|
flex: {
|
||||||
|
flex: 1,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
function Transition(props) {
|
||||||
|
return <Slide direction="up" {...props} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getIdeaFromStr = str => {
|
const getIdeaFromStr = str => {
|
||||||
|
@ -39,9 +55,17 @@ class Poll extends PureComponent {
|
||||||
|
|
||||||
constructor(props){
|
constructor(props){
|
||||||
super(props);
|
super(props);
|
||||||
this.state = { value: 0, balance: 0, isSubmitting: false };
|
this.state = { value: 0, balance: 0, isSubmitting: false, open: false };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleClickOpen = () => {
|
||||||
|
this.setState({ open: true });
|
||||||
|
};
|
||||||
|
|
||||||
|
handleClose = () => {
|
||||||
|
this.setState({ open: false });
|
||||||
|
};
|
||||||
|
|
||||||
handleChange = (event, value) => {
|
handleChange = (event, value) => {
|
||||||
this.setState({ value })
|
this.setState({ value })
|
||||||
};
|
};
|
||||||
|
@ -125,7 +149,7 @@ class Poll extends PureComponent {
|
||||||
const maxValue = Math.floor(Math.sqrt(balance));
|
const maxValue = Math.floor(Math.sqrt(balance));
|
||||||
const buttonText = originalValue != 0 && value != originalValue ? 'Change Vote' : 'Vote';
|
const buttonText = originalValue != 0 && value != originalValue ? 'Change Vote' : 'Vote';
|
||||||
const idea = getIdeaFromStr(_description)
|
const idea = getIdeaFromStr(_description)
|
||||||
const ideaSite = ideaSites.filter(site => site.includes(idea));
|
const ideaSite = ideaSites && ideaSites.filter(site => site.includes(idea));
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
|
@ -141,7 +165,30 @@ class Poll extends PureComponent {
|
||||||
{balance != 0 && !_canVote && <span>You can not vote on this poll</span>}
|
{balance != 0 && !_canVote && <span>You can not vote on this poll</span>}
|
||||||
</Typography>}
|
</Typography>}
|
||||||
{error && <Typography variant="body2" color="error">{error}</Typography>}
|
{error && <Typography variant="body2" color="error">{error}</Typography>}
|
||||||
{ideaSite.length && <Typography variant="subheading" color="primary">{ideaSite}</Typography>}
|
{ideaSite.length && <Typography onClick={this.handleClickOpen} variant="subheading" color="primary">{ideaSite}</Typography>}
|
||||||
|
{ideaSite && <Dialog
|
||||||
|
fullScreen
|
||||||
|
open={this.state.open}
|
||||||
|
onClose={this.handleClose}
|
||||||
|
TransitionComponent={Transition}
|
||||||
|
>
|
||||||
|
<AppBar className={classes.appBar} onClick={this.handleClose}>
|
||||||
|
<Toolbar>
|
||||||
|
<IconButton color="inherit" aria-label="Close">
|
||||||
|
<CloseIcon />
|
||||||
|
</IconButton>
|
||||||
|
<Typography variant="title" color="inherit" className={classes.flex}>
|
||||||
|
close
|
||||||
|
</Typography>
|
||||||
|
</Toolbar>
|
||||||
|
</AppBar>
|
||||||
|
<Iframe url={ideaSite[0]}
|
||||||
|
id="ideaSite"
|
||||||
|
className="ideaSite"
|
||||||
|
display="initial"
|
||||||
|
position="relative"
|
||||||
|
allowFullScreen/>
|
||||||
|
</Dialog>}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
{!cantVote && <CardActions className={classes.card}>
|
{!cantVote && <CardActions className={classes.card}>
|
||||||
<Slider style={{ width: '95%' }} classes={{ thumb: classes.thumb }} disabled={disableVote} value={value || 0} min={0} max={maxValue} step={1} onChange={this.handleChange} />
|
<Slider style={{ width: '95%' }} classes={{ thumb: classes.thumb }} disabled={disableVote} value={value || 0} min={0} max={maxValue} step={1} onChange={this.handleChange} />
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
"react-blockies": "^1.3.0",
|
"react-blockies": "^1.3.0",
|
||||||
"react-bootstrap": "^0.32.1",
|
"react-bootstrap": "^0.32.1",
|
||||||
"react-dom": "^16.3.2",
|
"react-dom": "^16.3.2",
|
||||||
|
"react-iframe": "^1.2.0",
|
||||||
"react-toggle": "^4.0.2",
|
"react-toggle": "^4.0.2",
|
||||||
"rlp": "^2.0.0",
|
"rlp": "^2.0.0",
|
||||||
"typeface-roboto": "0.0.54"
|
"typeface-roboto": "0.0.54"
|
||||||
|
|
Loading…
Reference in New Issue