fix render

This commit is contained in:
Ricardo Guilherme Schmidt 2019-04-29 09:39:15 -03:00
parent 3660721c24
commit 8c7337b709
No known key found for this signature in database
GPG Key ID: 3F95A3AD0B607030
2 changed files with 12 additions and 12 deletions

View File

@ -73,11 +73,11 @@ class TopicDemocracy extends React.Component {
</Toolbar>
</AppBar>
<main className={classes.layout}>
<Route exact path="/" render={(match) => (
<Route exact path="/" render={({ match }) => (
<DelegationFactoryUI account={defaultAccount} />
)} />
<Route path="/:address" render={(match) => (
<DelegationUI account={defaultAccount} Delegation={new EmbarkJS.Blockchain.Contract({ abi: Delegation._jsonInterface, address: match.param.address }) } />
<Route path="/:address" render={({ match }) => (
<DelegationUI account={defaultAccount} Delegation={new EmbarkJS.Blockchain.Contract({ abi: Delegation._jsonInterface, address: match.params.address }) } />
)} />
</main>
</HashRouter>

View File

@ -17,7 +17,7 @@ class DelegationUI extends React.Component {
constructor(props) {
super(props);
this.state = {
delegation: [],
delegate: null,
delegateChain: [],
editDelegate: null,
editDelegation: [],
@ -36,7 +36,7 @@ class DelegationUI extends React.Component {
if(!delegateChain.includes(delegate)){
delegateChain.push(delegate);
this.setState({delegateChain});
this.props.Delegation.methods.delegatedTo(delegate).then((delegatedTo) => {
this.props.Delegation.methods.delegatedTo(delegate).call().then((delegatedTo) => {
this.delegateChainOf(delegatedTo);
});
}
@ -47,18 +47,18 @@ class DelegationUI extends React.Component {
if(!delegateChain.includes(delegate)){
delegateChain.push(delegate);
this.setState({delegateChain});
this.props.Delegation.methods.delegatedTo(delegate).then((delegatedTo) => {
this.props.Delegation.methods.delegatedTo(delegate).call().then((delegatedTo) => {
this.delegateChainOf(delegatedTo);
});
}
}
editDelegationOf(delegate) {
const delegateChain = this.state.editDelegation;
const editDelegation = this.state.editDelegation;
if(!delegateChain.includes(delegate)){
editDelegation.push(delegate);
this.setState({editDelegation});
this.props.Delegation.methods.delegatedTo(delegate).then((delegatedTo) => {
this.props.Delegation.methods.delegatedTo(delegate).call().then((delegatedTo) => {
this.editDelegationOf(delegatedTo);
});
}
@ -71,7 +71,7 @@ class DelegationUI extends React.Component {
Delegation,
className,
} = this.props;
const { delegateChain, editDelegate } = this.state;
const {delegate, delegateChain, editDelegate, editDelegation } = this.state;
return (
<div className={className} >
@ -83,15 +83,15 @@ class DelegationUI extends React.Component {
<small>Delegate Chain:</small>
<Breadcrumbs arial-label="Breadcrumb" maxItems={5}>
{
delegateChain.map((value) => {
return <EthAddress value={value} />
delegateChain.map((value, i) => {
return <EthAddress key={i} value={value} />
})
}
</Breadcrumbs>
</div>
<div>
<p>Delegate Set</p>
<EthAddress defaultValue={delegateChain[0]} control={true} onChange={(editDelegate) => {
<EthAddress defaultValue={editDelegate} control={true} onChange={(editDelegate) => {
this.setState({editDelegate});
if(editDelegate != delegateChain[0]) {
this.setState({editDelegation : []});