2018-06-26 12:46:06 -04:00
import React from 'react' ;
import PropTypes from 'prop-types' ;
import { withStyles } from '@material-ui/core/styles' ;
import AppBar from '@material-ui/core/AppBar' ;
import Toolbar from '@material-ui/core/Toolbar' ;
import Typography from '@material-ui/core/Typography' ;
import Button from '@material-ui/core/Button' ;
import IconButton from '@material-ui/core/IconButton' ;
import MenuIcon from '@material-ui/icons/Menu' ;
2018-06-29 07:22:07 -04:00
import Hidden from '@material-ui/core/Hidden' ;
2018-06-29 11:24:48 -04:00
import OrderingFilter from '../simple-voting/OrderingFilter' ;
2018-06-28 16:24:28 -04:00
import { VotingContext } from '../../context' ;
const hasSnt = snt => Number ( snt . balance ) > 0 ;
2018-06-26 12:46:06 -04:00
const styles = {
root : {
flexGrow : 1 ,
2018-06-29 07:22:07 -04:00
fontSize : '16px' ,
2018-06-26 12:46:06 -04:00
} ,
2018-06-29 07:22:07 -04:00
text : {
2018-06-26 12:46:06 -04:00
flex : 1 ,
} ,
menuButton : {
marginLeft : - 12 ,
marginRight : 20 ,
} ,
2018-06-29 07:22:07 -04:00
toolBar : {
display : 'flex' ,
justifyContent : 'space-around'
}
2018-06-26 12:46:06 -04:00
} ;
function ButtonAppBar ( props ) {
2018-06-28 16:24:28 -04:00
const { classes , togglePoll } = props ;
2018-06-26 12:46:06 -04:00
return (
2018-06-28 16:24:28 -04:00
< VotingContext . Consumer >
2018-06-29 07:22:07 -04:00
{ ( { snt , toggleAdmin } ) =>
< div className = { classes . root } >
< AppBar position = "static" >
< Toolbar className = { classes . toolBar } >
2018-06-29 11:24:48 -04:00
< Hidden mdDown >
2018-06-28 16:40:18 -04:00
< IconButton className = { classes . menuButton } color = "inherit" aria - label = "Menu" onClick = { toggleAdmin } / >
2018-06-29 07:22:07 -04:00
< / H i d d e n >
< Hidden smDown >
2018-06-28 16:24:28 -04:00
< Typography variant = "display1" color = "inherit" className = { classes . flex } >
What should we build next ?
< / T y p o g r a p h y >
2018-06-29 07:22:07 -04:00
< / H i d d e n >
2018-06-29 11:24:48 -04:00
{ snt && < Button disabled = { ! hasSnt ( snt ) } variant = "outlined" color = "inherit" onClick = { togglePoll } > { hasSnt ( snt ) ? 'Add Proposal' : 'Your account has no SNT' } < / B u t t o n > }
< OrderingFilter / >
2018-06-29 07:22:07 -04:00
< / T o o l b a r >
< / A p p B a r >
< / d i v >
}
2018-06-28 16:24:28 -04:00
< / V o t i n g C o n t e x t . C o n s u m e r >
2018-06-26 12:46:06 -04:00
) ;
}
ButtonAppBar . propTypes = {
classes : PropTypes . object . isRequired ,
} ;
export default withStyles ( styles ) ( ButtonAppBar ) ;