Merge branch '000-snt-voting-dapp' of https://github.com/status-im/contracts into 000-snt-voting-dapp

This commit is contained in:
Richard Ramos 2018-06-27 13:27:27 -04:00
commit b96ecd5a20
3 changed files with 34 additions and 3 deletions

View File

@ -3,11 +3,13 @@ import CssBaseline from '@material-ui/core/CssBaseline';
import 'typeface-roboto';
import AppBar from './standard/AppBar';
import AddPoll from './simple-voting/AddPoll';
import PollsList from './simple-voting/PollsList';
export default ({ toggleAdmin }) => (
export default ({ toggleAdmin, rawPolls }) => (
<Fragment>
<CssBaseline />
<AppBar toggleAdmin={toggleAdmin} />
<AddPoll />
{rawPolls && <PollsList rawPolls={rawPolls} />}
</Fragment>
)

View File

@ -0,0 +1,27 @@
import React, { Fragment } from 'react';
import Card from '@material-ui/core/Card';
import CardContent from '@material-ui/core/CardContent';
import Button from '@material-ui/core/Button';
import Typography from '@material-ui/core/Typography';
const Poll = ({ _question, _totalCensus, _voters }) => (
<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>
</Card>
)
const PollsList = ({ rawPolls }) => (
<Fragment>
{rawPolls.map(poll => <Poll {...poll} />)}
</Fragment>
)
export default PollsList

View File

@ -51,11 +51,13 @@ class App extends React.Component {
}
render(){
const { admin } = this.state;
const { admin, rawPolls } = this.state;
const toggleAdmin = () => this.setState({ admin: true });
return (
<Fragment>
{admin ? <AdminView setAccount={this.setAccount} /> : <Voting toggleAdmin={toggleAdmin} />}
{admin ?
<AdminView setAccount={this.setAccount} /> :
<Voting toggleAdmin={toggleAdmin} rawPolls={rawPolls} />}
</Fragment>
);
}