import EmbarkJS from 'Embark/EmbarkJS'; import {{contractName}} from 'Embark/contracts/{{contractName}}'; import React from 'react'; import ReactDOM from 'react-dom'; import { FormGroup, ControlLabel, FormControl, Button } from 'react-bootstrap'; {{#each functions}} class {{capitalize name}}_{{@index}}_Form extends React.Component { constructor(props){ super(props); this.state = { {{#if inputs.length}} input: { {{#each inputs}} {{name}}: ''{{#unless @last}},{{/unless}} {{/each}} }, {{/if}} {{#ifview stateMutability}} output: null, {{/ifview}} message: '' }; } handleChange(e, name){ this.state[name] = e.target.value; this.setState(this.state); } async handleClick(e){ e.preventDefault(); {{#ifview stateMutability}} this.setState({output: null}); let result = await {{../contractName}}.methods{{methodname ../functions name inputs}}({{#each inputs}}this.state.{{name}}{{#unless @last}}, {{/unless}}{{/each}}).call(); {{#ifarrlengthgt outputs 1}} this.setState({output: { {{#each outputs}} {{emptyname name @index}}: result[{{@index}}]{{#unless @last}},{{/unless}} {{/each}} }}); {{else}} this.setState({output: result}); {{/ifarrlengthgt}} // TODO show on screen {{/ifview}} // TODO validate } render(){ return

{{name}}

{{#if inputs.length}} {{#each inputs}} {{name}} this.handleChange(e, '{{name}}')} /> {{/each}} {{/if}} {{#ifview stateMutability}} { this.state.output != null ?

Results

{{#ifarrlengthgt outputs 1}}
    {{#each outputs}}
  • {{emptyname name @index}}: { this.state.output.{{emptyname name @index}} }
  • {{/each}}
{{else}} {this.state.output} {{/ifarrlengthgt}}
: '' } {{/ifview}}
; } } {{/each}} class {{contractName}}UI extends React.Component { constructor (props) { super(props); this.state = { }; } render(){ return (
{{#each functions}} <{{capitalize name}}_{{@index}}_Form /> {{/each}}
); } } ReactDOM.render(

{{title}}

<{{contractName}}UI />
, document.getElementById('app') );