add AddPoll component

This commit is contained in:
Barry Gitarts 2018-06-26 16:34:52 -04:00
parent 6e6247593c
commit 1bf51552d7
2 changed files with 74 additions and 0 deletions

View File

@ -2,10 +2,12 @@ import React, { Fragment } from 'react';
import CssBaseline from '@material-ui/core/CssBaseline';
import 'typeface-roboto';
import AppBar from './standard/AppBar';
import AddPoll from './simple-voting/AddPoll';
export default ({ toggleAdmin }) => (
<Fragment>
<CssBaseline />
<AppBar toggleAdmin={toggleAdmin} />
<AddPoll />
</Fragment>
)

View File

@ -0,0 +1,72 @@
import React, { Fragment } from 'react';
import Card from '@material-ui/core/Card';
import CardActions from '@material-ui/core/CardActions';
import CardContent from '@material-ui/core/CardContent';
import PollManager from 'Embark/contracts/PollManager';
import TextField from '@material-ui/core/TextField';
import Button from '@material-ui/core/Button';
import { withStyles } from '@material-ui/core/styles';
import { withFormik } from 'formik';
const styles = theme => ({
button: {
margin: theme.spacing.unit,
},
extendedIcon: {
marginRight: theme.spacing.unit,
},
textField: {
marginLeft: theme.spacing.unit,
marginRight: theme.spacing.unit
},
inputLabel: {
fontSize: '16px'
},
form: {
display: 'flex',
flexDirection: 'column'
}
});
const InnerForm = ({
values,
errors,
touched,
handleChange,
handleBlur,
handleSubmit,
isSubmitting,
classes
}) => (
<Card>
<CardContent>
<form onSubmit={handleSubmit} className={classes.form}>
<TextField
id="description"
label="description"
className={classes.textField}
value={values.description}
onChange={handleChange}
margin="normal"
fullWidth
error={errors.description}
/>
<Button type="submit" variant="extendedFab" aria-label="add" className={classes.button}>Submit</Button>
</form>
</CardContent>
</Card>
)
const StyledForm = withStyles(styles)(InnerForm);
const AddPoll = withFormik({
mapPropsToValues: props => ({ description: ''}),
validate(values){
const errors = {};
return errors;
},
handleSubmit(values) {
}
})(StyledForm)
export default AddPoll;