Skip to content

Commit

Permalink
Improve REStake UX
Browse files Browse the repository at this point in the history
  • Loading branch information
tombeynon committed Mar 2, 2022
1 parent 4a3595b commit e6d8e3a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 35 deletions.
6 changes: 1 addition & 5 deletions src/components/DelegateForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,7 @@ class DelegateForm extends React.Component {
actionText(){
if(this.props.redelegate) return 'Redelegate'
if(this.props.undelegate) return 'Undelegate'
if(this.props.validator){
return 'Delegate'
}else{
return 'Add Validator'
}
return 'Delegate'
}

denom(){
Expand Down
52 changes: 23 additions & 29 deletions src/components/Delegations.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class Delegations extends React.Component {
this.props.restClient.getGrants(this.props.network.data.testaddress, this.props.address)
.then(
(result) => { }, (error) => {
if (error.response.status === 501) {
if (error.response && error.response.status === 501) {
this.setState({ authzMissing: true });
}
})
Expand Down Expand Up @@ -227,34 +227,31 @@ class Delegations extends React.Component {
stargateClient={this.props.stargateClient}
onDelegate={this.onClaimRewards}>{validator.description.moniker}</Delegate>
</td>
<td className="d-none d-sm-table-cell text-center">{operator ? <CheckCircle className="text-success" /> : <XCircle className="opacity-50" />}</td>
<td className="text-center">
{operator ? this.restakePossible() ? (
this.grantsValid(operator) ? (
<RevokeRestake
size="sm" variant="outline-danger"
address={this.props.address}
operator={operator}
stargateClient={this.props.stargateClient}
onRevoke={this.onRevoke}
setError={this.setError} />
) : (
<GrantRestake
size="sm" variant="outline-success"
address={this.props.address}
operator={operator}
stargateClient={this.props.stargateClient}
onGrant={this.onGrant}
setError={this.setError} />
)
) : <CheckCircle className="text-success" /> : <XCircle className="opacity-50" />}
</td>
<td className="d-none d-lg-table-cell">{validator.commission.commission_rates.rate * 100}%</td>
<td className="d-none d-lg-table-cell"></td>
<td className="d-none d-sm-table-cell"><Coins coins={item.balance} /></td>
<td className="d-none d-sm-table-cell">{rewards && rewards.reward.map(el => <Coins key={el.denom} coins={el} />)}</td>
{this.restakePossible() && (
<td>
{operator && (
this.grantsValid(operator) ? (
<RevokeRestake
size="sm" variant="outline-danger"
address={this.props.address}
operator={operator}
stargateClient={this.props.stargateClient}
onRevoke={this.onRevoke}
setError={this.setError} />
) : (
<GrantRestake
size="sm" variant="outline-success"
address={this.props.address}
operator={operator}
stargateClient={this.props.stargateClient}
onGrant={this.onGrant}
setError={this.setError} />
)
)}
</td>
)}
<td>
<div className="d-grid gap-2 d-md-flex justify-content-end">
{!this.state.validatorLoading[validatorAddress]
Expand Down Expand Up @@ -390,14 +387,11 @@ class Delegations extends React.Component {
<thead>
<tr>
<th colSpan={2}>Validator</th>
<th className="d-none d-sm-table-cell text-center">Operator</th>
<th className="d-none d-sm-table-cell text-center">REStake</th>
<th className="d-none d-lg-table-cell">Commission</th>
<th className="d-none d-lg-table-cell">APY</th>
<th className="d-none d-sm-table-cell">Delegation</th>
<th className="d-none d-sm-table-cell">Rewards</th>
{this.restakePossible() &&
<th>REStake</th>
}
<th width={110}></th>
</tr>
</thead>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function Validators(props) {
<tbody>
<tr>
<th>Validator</th>
<th className="text-center">Operator</th>
<th className="text-center">REStake</th>
<th></th>
</tr>
{filteredOperators.map(([validator_address, item], i) => renderItem(item, true))}
Expand Down

0 comments on commit e6d8e3a

Please sign in to comment.