mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
cleanup, keep render function short
This commit is contained in:
parent
f21706bcf3
commit
acef1130cb
@ -13,7 +13,7 @@ interface FaucetState {
|
|||||||
eth?: string
|
eth?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
class Faucet extends PureComponent<{}, FaucetState> {
|
export default class Faucet extends PureComponent<{}, FaucetState> {
|
||||||
public state = {
|
public state = {
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
success: undefined,
|
success: undefined,
|
||||||
@ -37,6 +37,50 @@ class Faucet extends PureComponent<{}, FaucetState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private RequestMarkup = () => (
|
||||||
|
<User.Consumer>
|
||||||
|
{states => (
|
||||||
|
<Button
|
||||||
|
primary
|
||||||
|
onClick={() => this.getTokens(states.requestFromFaucet)}
|
||||||
|
>
|
||||||
|
Request Ether
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</User.Consumer>
|
||||||
|
)
|
||||||
|
|
||||||
|
private ActionMarkup = () => (
|
||||||
|
<div className={styles.action}>
|
||||||
|
{this.state.isLoading ? (
|
||||||
|
<Spinner message="Getting Ether..." />
|
||||||
|
) : this.state.error ? (
|
||||||
|
<div className={styles.error}>
|
||||||
|
{this.state.error}{' '}
|
||||||
|
<Button link onClick={this.reset}>
|
||||||
|
Try again
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
) : this.state.success ? (
|
||||||
|
<div className={styles.success}>{this.state.success}</div>
|
||||||
|
) : (
|
||||||
|
<this.RequestMarkup />
|
||||||
|
)}
|
||||||
|
|
||||||
|
<p>
|
||||||
|
You can only request Ether once every 24 hours for your address.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
|
||||||
|
private reset = () => {
|
||||||
|
this.setState({
|
||||||
|
error: undefined,
|
||||||
|
success: undefined,
|
||||||
|
isLoading: false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
return (
|
return (
|
||||||
<Route
|
<Route
|
||||||
@ -45,38 +89,8 @@ class Faucet extends PureComponent<{}, FaucetState> {
|
|||||||
>
|
>
|
||||||
<Web3message />
|
<Web3message />
|
||||||
|
|
||||||
<div className={styles.action}>
|
<this.ActionMarkup />
|
||||||
<User.Consumer>
|
|
||||||
{states =>
|
|
||||||
this.state.isLoading ? (
|
|
||||||
<Spinner message="Getting Ether..." />
|
|
||||||
) : this.state.error ? (
|
|
||||||
this.state.error
|
|
||||||
) : this.state.success ? (
|
|
||||||
<div className={styles.success}>
|
|
||||||
{this.state.success}
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<Button
|
|
||||||
primary
|
|
||||||
onClick={() =>
|
|
||||||
this.getTokens(states.requestFromFaucet)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Request Ether
|
|
||||||
</Button>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
</User.Consumer>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
You can only request Ether once every 24 hours for your
|
|
||||||
address.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</Route>
|
</Route>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Faucet
|
|
||||||
|
Loading…
Reference in New Issue
Block a user