Skip to content

Commit

Permalink
chore(testInvoke): small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Maurice Dalderup authored and Maurice Dalderup committed May 19, 2018
1 parent 14306c2 commit 778fe09
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/app/containers/TestInvoke/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ export default class TestInvoke extends Component {
this.setState({ args: this.state.args.concat(['']) })
}

_handleRemoveArg = id => {
_handleRemoveArg = (id, e) => {
e.preventDefault()
this.setState({ args: this.state.args.filter((s, idx) => id !== idx) })
}

_handleSubmit = event => {
event.preventDefault()
_handleSubmit = e => {
e.preventDefault()
const { selectedNetworkId, networks } = this.props
const { scriptHash, operation, args } = this.state
this.setState({
Expand Down Expand Up @@ -119,7 +120,7 @@ export default class TestInvoke extends Component {
render() {
const { result, loading, errorMsg } = this.state
return (
<div>
<React.Fragment>
<form>
<div className={ tempStyle.tempFormStyle }>
<TextField
Expand Down Expand Up @@ -150,7 +151,12 @@ export default class TestInvoke extends Component {
id={ `Argument #${idx + 1} name` }
onChange={ (event) => this._handleArgChange(idx, event) }
/>
<Button raised ripple style={ { flexGrow: 0, order: 0 } } onClick={ () => this._handleRemoveArg(idx) }>
<Button
key={ `btn-${idx + 1}` }
raised
ripple
style={ { flexGrow: 0, order: 0 } }
onClick={ (event) => this._handleRemoveArg(idx, event) }>
-
</Button>
</React.Fragment>
Expand All @@ -174,7 +180,7 @@ export default class TestInvoke extends Component {
)}
{loading && <div>Loading...</div>}
{errorMsg !== '' && <div>ERROR: {errorMsg}</div>}
</div>
</React.Fragment>
)
}
}
Expand Down

0 comments on commit 778fe09

Please sign in to comment.