2018-01-06 03:26:57 +01:00
import React from 'react' ;
2018-01-10 03:25:38 +01:00
import { setPublishInChannel } from '../actions' ;
import { connect } from 'react-redux' ;
2018-01-06 03:26:57 +01:00
class AnonymousOrChannelSelect extends React . Component {
constructor ( props ) {
super ( props ) ;
this . toggleAnonymousPublish = this . toggleAnonymousPublish . bind ( this ) ;
}
toggleAnonymousPublish ( event ) {
const value = event . target . value ;
if ( value === 'anonymous' ) {
2018-01-10 03:25:38 +01:00
this . props . onPublishToChannelChange ( false ) ;
2018-01-06 03:26:57 +01:00
} else {
2018-01-10 03:25:38 +01:00
this . props . onPublishToChannelChange ( true ) ;
2018-01-06 03:26:57 +01:00
}
}
render ( ) {
return (
< div className = "row row--padded row--short row--wide" >
< div className = "column column--10" >
< form >
< div className = "column column--3 column--med-10" >
2018-01-10 03:25:38 +01:00
< input type = "radio" name = "anonymous-or-channel" id = "anonymous-radio" className = "input-radio" value = "anonymous" checked = { ! this . props . publishInChannel } onChange = { this . toggleAnonymousPublish } / >
2018-01-06 03:26:57 +01:00
< label className = "label label--pointer" htmlFor = "anonymous-radio" > Anonymous < / label >
< / div >
< div className = "column column--7 column--med-10" >
2018-01-10 03:25:38 +01:00
< input type = "radio" name = "anonymous-or-channel" id = "channel-radio" className = "input-radio" value = "in a channel" checked = { this . props . publishInChannel } onChange = { this . toggleAnonymousPublish } / >
2018-01-06 03:26:57 +01:00
< label className = "label label--pointer" htmlFor = "channel-radio" > In a channel < / label >
< / div >
< / form >
< / div >
< / div >
) ;
}
}
2018-01-10 03:25:38 +01:00
const mapStateToProps = state => {
return {
publishInChannel : state . publishInChannel ,
} ;
} ;
const mapDispatchToProps = dispatch => {
return {
onPublishToChannelChange : ( value ) => {
dispatch ( setPublishInChannel ( value ) ) ;
} ,
} ;
}
export default connect ( mapStateToProps , mapDispatchToProps ) ( AnonymousOrChannelSelect ) ;