mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-01-24 22:19:37 +00:00
Alert for error invoking functions
This commit is contained in:
parent
ee02404484
commit
2679e60860
@ -3,7 +3,7 @@ import {{contractName}} from 'Embark/contracts/{{contractName}}';
|
|||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import { FormGroup, ControlLabel, FormControl, Checkbox, Button } from 'react-bootstrap';
|
import { FormGroup, ControlLabel, FormControl, Checkbox, Button, Alert } from 'react-bootstrap';
|
||||||
|
|
||||||
|
|
||||||
{{#each functions}}
|
{{#each functions}}
|
||||||
@ -21,7 +21,7 @@ class {{capitalize name}}_{{@index}}_Form extends React.Component {
|
|||||||
{{#ifview stateMutability}}
|
{{#ifview stateMutability}}
|
||||||
output: null,
|
output: null,
|
||||||
{{/ifview}}
|
{{/ifview}}
|
||||||
message: ''
|
error: null
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,9 +37,10 @@ class {{capitalize name}}_{{@index}}_Form extends React.Component {
|
|||||||
|
|
||||||
async handleClick(e){
|
async handleClick(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.setState({output: null});
|
this.setState({output: null, error: null});
|
||||||
|
|
||||||
{{#ifview stateMutability}}
|
{{#ifview stateMutability}}
|
||||||
|
try {
|
||||||
{{../contractName}}.methods{{methodname ../functions name inputs}}({{#each inputs}}this.state.input.{{name}}{{#unless @last}}, {{/unless}}{{/each}})
|
{{../contractName}}.methods{{methodname ../functions name inputs}}({{#each inputs}}this.state.input.{{name}}{{#unless @last}}, {{/unless}}{{/each}})
|
||||||
.call()
|
.call()
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
@ -52,7 +53,13 @@ class {{capitalize name}}_{{@index}}_Form extends React.Component {
|
|||||||
{{else}}
|
{{else}}
|
||||||
this.setState({output: result});
|
this.setState({output: result});
|
||||||
{{/iflengthgt}}
|
{{/iflengthgt}}
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
this.setState({error: err.message});
|
||||||
});
|
});
|
||||||
|
} catch(err) {
|
||||||
|
this.setState({error: err.message});
|
||||||
|
}
|
||||||
|
|
||||||
// TODO show on screen
|
// TODO show on screen
|
||||||
{{/ifview}}
|
{{/ifview}}
|
||||||
@ -63,6 +70,11 @@ class {{capitalize name}}_{{@index}}_Form extends React.Component {
|
|||||||
render(){
|
render(){
|
||||||
return <div className="formSection">
|
return <div className="formSection">
|
||||||
<h3>{{name}}</h3>
|
<h3>{{name}}</h3>
|
||||||
|
{
|
||||||
|
this.state.error != null ?
|
||||||
|
<Alert bsStyle="danger">{this.state.error}</Alert>
|
||||||
|
: ''
|
||||||
|
}
|
||||||
<form>
|
<form>
|
||||||
{{#if inputs.length}}
|
{{#if inputs.length}}
|
||||||
{{#each inputs}}
|
{{#each inputs}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user