Skip to content

Commit

Permalink
Merge pull request #612 from blockchain/selectBox-validator
Browse files Browse the repository at this point in the history
set touched when dropdown, forces to validate
  • Loading branch information
schnogz committed Jun 19, 2018
2 parents d47e69c + 39db68f commit d3c203e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ import Loading from './template.loading'
import Success from './template.success'

class FirstStep extends React.Component {
constructor (props) {
super(props)
this.handleToToggle = this.handleToToggle.bind(this)
}

handleToToggle (val) {
this.props.formActions.touch('sendBch', 'to')
this.props.actions.sendBchFirstStepToToggled(val)
}

render () {
const { data, actions } = this.props

Expand All @@ -21,7 +31,7 @@ class FirstStep extends React.Component {
effectiveBalance={value.effectiveBalance}
totalFee={value.totalFee}
onSubmit={() => actions.sendBchFirstStepSubmitClicked()}
handleToToggle={(val) => actions.sendBchFirstStepToToggled(val)}
handleToToggle={this.handleToToggle}
/>,
Failure: (message) => <Error>{message}</Error>,
Loading: () => <Loading />,
Expand All @@ -35,7 +45,8 @@ const mapStateToProps = state => ({
})

const mapDispatchToProps = dispatch => ({
actions: bindActionCreators(actions.components.sendBch, dispatch)
actions: bindActionCreators(actions.components.sendBch, dispatch),
formActions: bindActionCreators(actions.form, dispatch)
})

export default connect(mapStateToProps, mapDispatchToProps)(FirstStep)
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@ class FirstStep extends React.Component {
constructor (props) {
super(props)
this.handleRefresh = this.handleRefresh.bind(this)
this.handleToToggle = this.handleToToggle.bind(this)
}

handleRefresh () {
this.props.refreshActions.refresh()
}

handleToToggle (val) {
this.props.formActions.touch('sendBtc', 'to')
this.props.actions.sendBtcFirstStepToToggled(val)
}

render () {
const { data, actions } = this.props

Expand All @@ -40,7 +46,7 @@ class FirstStep extends React.Component {
totalFee={value.totalFee}
onSubmit={() => actions.sendBtcFirstStepSubmitClicked()}
handleFeePerByteToggle={() => actions.sendBtcFirstStepFeePerByteToggled()}
handleToToggle={(val) => actions.sendBtcFirstStepToToggled(val)}
handleToToggle={this.handleToToggle}
/>,
Failure: () => <DataError onClick={() => this.handleRefresh} />,
NotAsked: () => <Loading />,
Expand All @@ -56,7 +62,8 @@ const mapStateToProps = state => ({

const mapDispatchToProps = dispatch => ({
refreshActions: bindActionCreators(actions.core.refresh, dispatch),
actions: bindActionCreators(actions.components.sendBtc, dispatch)
actions: bindActionCreators(actions.components.sendBtc, dispatch),
formActions: bindActionCreators(actions.form, dispatch)
})

export default connect(mapStateToProps, mapDispatchToProps)(FirstStep)

0 comments on commit d3c203e

Please sign in to comment.