mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-01-09 13:36:14 +00:00
Disabling button while loading
This commit is contained in:
parent
db8ebd6a83
commit
2524a945f7
@ -25,7 +25,8 @@ class {{capitalize name}}Form{{@index}} extends React.Component {
|
|||||||
output: null,
|
output: null,
|
||||||
{{/ifview}}
|
{{/ifview}}
|
||||||
error: null,
|
error: null,
|
||||||
mined: null
|
mined: null,
|
||||||
|
loading: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,13 +54,13 @@ class {{capitalize name}}Form{{@index}} extends React.Component {
|
|||||||
{{#each outputs}}
|
{{#each outputs}}
|
||||||
{{emptyname name @index}}: result[{{@index}}]{{#unless @last}},{{/unless}}
|
{{emptyname name @index}}: result[{{@index}}]{{#unless @last}},{{/unless}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
}});
|
}, loading: false});
|
||||||
{{else}}
|
{{else}}
|
||||||
this.setState({output: result});
|
this.setState({output: result, loading: false});
|
||||||
{{/iflengthgt}}
|
{{/iflengthgt}}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
this.setState({error: err.message});
|
this.setState({error: err.message, loading: false});
|
||||||
});
|
});
|
||||||
{{else}}
|
{{else}}
|
||||||
{{../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}})
|
||||||
@ -71,15 +72,15 @@ class {{capitalize name}}Form{{@index}} extends React.Component {
|
|||||||
})
|
})
|
||||||
.then((_receipt) => {
|
.then((_receipt) => {
|
||||||
console.log(_receipt);
|
console.log(_receipt);
|
||||||
this.setState({receipt: _receipt})
|
this.setState({receipt: _receipt, loading: false})
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
this.setState({error: err.message});
|
this.setState({error: err.message, loading: false});
|
||||||
});
|
});
|
||||||
{{/ifview}}
|
{{/ifview}}
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
this.setState({error: err.message});
|
this.setState({error: err.message, loading: false});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +128,7 @@ class {{capitalize name}}Form{{@index}} extends React.Component {
|
|||||||
: ''
|
: ''
|
||||||
}
|
}
|
||||||
{{#ifview stateMutability}}
|
{{#ifview stateMutability}}
|
||||||
<Button type="submit" bsStyle="primary" onClick={(e) => this.handleClick(e)}>Call</Button>
|
<Button disabled={this.state.loading} type="submit" bsStyle="primary" onClick={(e) => this.handleClick(e)}>Call</Button>
|
||||||
{
|
{
|
||||||
this.state.output != null ?
|
this.state.output != null ?
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
@ -145,7 +146,7 @@ class {{capitalize name}}Form{{@index}} extends React.Component {
|
|||||||
: ''
|
: ''
|
||||||
}
|
}
|
||||||
{{else}}
|
{{else}}
|
||||||
<Button type="submit" bsStyle="primary" onClick={(e) => this.handleClick(e)}>Send</Button>
|
<Button disabled={this.state.loading} type="submit" bsStyle="primary" onClick={(e) => this.handleClick(e)}>{this.state.loading ? 'Sending...' : 'Send'}</Button>
|
||||||
{
|
{
|
||||||
this.state.receipt != null ?
|
this.state.receipt != null ?
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user