update ui on submit

This commit is contained in:
Richard Ramos 2019-03-08 18:19:33 -04:00
parent f9f6201393
commit 8c69fbf792

View File

@ -102,7 +102,7 @@ class App extends React.Component {
return this.setState({error: err.message || err}); return this.setState({error: err.message || err});
} }
this.loadContributor(); this.getCurrentContributorData();
this.getContributors(); this.getContributors();
}); });
@ -124,7 +124,16 @@ class App extends React.Component {
this.setState({ praise: e.target.value }); this.setState({ praise: e.target.value });
} }
async loadContributor(){ resetUIFields(){
this.setState({
praise: '',
selectedContributors: [],
error: '',
award: 0
})
}
async getCurrentContributorData(){
const currentContributor = await this.getContributor(web3.eth.defaultAccount); const currentContributor = await this.getContributor(web3.eth.defaultAccount);
this.setState({currentContributor}); this.setState({currentContributor});
} }
@ -167,9 +176,8 @@ class App extends React.Component {
const estimatedGas = await toSend.estimateGas({from: web3.eth.defaultAccount}); const estimatedGas = await toSend.estimateGas({from: web3.eth.defaultAccount});
const receipt = await toSend.send({from: web3.eth.defaultAccount, gas: estimatedGas + 1000}); const receipt = await toSend.send({from: web3.eth.defaultAccount, gas: estimatedGas + 1000});
// TODO: update UI this.getCurrentContributorData();
// TODO: empty fields this.resetUIFields();
} catch(e) { } catch(e) {
console.log('tx failed? got enough tokens to award?'); console.log('tx failed? got enough tokens to award?');
console.log(e); console.log(e);
@ -196,7 +204,7 @@ class App extends React.Component {
const estimatedGas = await toSend.estimateGas({from: web3.eth.defaultAccount}); const estimatedGas = await toSend.estimateGas({from: web3.eth.defaultAccount});
const receipt = await toSend.send({from: web3.eth.defaultAccount, gas: estimatedGas + 1000}); const receipt = await toSend.send({from: web3.eth.defaultAccount, gas: estimatedGas + 1000});
// TODO: update UI this.getCurrentContributorData();
} catch(e) { } catch(e) {
console.log('tx failed? Did you allocate all your tokens first?'); console.log('tx failed? Did you allocate all your tokens first?');
} }