mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
copy, success feedback for faucet action
This commit is contained in:
parent
c9abfa0890
commit
825bb7a0ee
@ -2,23 +2,32 @@ import React, { PureComponent } from 'react'
|
|||||||
import Button from '../../atoms/Button'
|
import Button from '../../atoms/Button'
|
||||||
import { User } from '../../../context/User'
|
import { User } from '../../../context/User'
|
||||||
|
|
||||||
|
interface FaucetProps {
|
||||||
|
togglePopover: any
|
||||||
|
}
|
||||||
|
|
||||||
interface FaucetState {
|
interface FaucetState {
|
||||||
isLoading: boolean
|
isLoading: boolean
|
||||||
|
success?: string
|
||||||
error?: string
|
error?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Faucet extends PureComponent<{}, FaucetState> {
|
export default class Faucet extends PureComponent<FaucetProps, FaucetState> {
|
||||||
public state = {
|
public state = {
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
|
success: undefined,
|
||||||
error: undefined
|
error: undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
private getTokens = async (requestFromFaucet: any) => {
|
private getTokens = async (requestFromFaucet: any) => {
|
||||||
|
// prevent popup from closing on click
|
||||||
|
this.props.togglePopover()
|
||||||
|
|
||||||
this.setState({ isLoading: true })
|
this.setState({ isLoading: true })
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await requestFromFaucet()
|
await requestFromFaucet()
|
||||||
this.setState({ isLoading: false })
|
this.setState({ isLoading: false, success: 'Tokens added!' })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.setState({ isLoading: false, error })
|
this.setState({ isLoading: false, error })
|
||||||
}
|
}
|
||||||
@ -32,6 +41,8 @@ export default class Faucet extends PureComponent<{}, FaucetState> {
|
|||||||
'Getting tokens...'
|
'Getting tokens...'
|
||||||
) : this.state.error ? (
|
) : this.state.error ? (
|
||||||
this.state.error
|
this.state.error
|
||||||
|
) : this.state.success ? (
|
||||||
|
this.state.success
|
||||||
) : (
|
) : (
|
||||||
<Button
|
<Button
|
||||||
link
|
link
|
||||||
@ -39,7 +50,7 @@ export default class Faucet extends PureComponent<{}, FaucetState> {
|
|||||||
this.getTokens(states.requestFromFaucet)
|
this.getTokens(states.requestFromFaucet)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
Make it rain
|
Request Ether & Ocean
|
||||||
</Button>
|
</Button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,23 @@ const Popover = ({ togglePopover }: { togglePopover: any }) => (
|
|||||||
onMouseOver={togglePopover}
|
onMouseOver={togglePopover}
|
||||||
onMouseOut={togglePopover}
|
onMouseOut={togglePopover}
|
||||||
>
|
>
|
||||||
|
<div className={styles.popoverInfoline}>
|
||||||
|
<span className={styles.balance} title="Fake data">
|
||||||
|
<strong>30</strong> ETH
|
||||||
|
</span>
|
||||||
|
{/* <span className={styles.balance} title={(eth / 1e18).toFixed(10)}>
|
||||||
|
<strong>{(eth / 1e18).toFixed(3).slice(0, -1)}</strong> ETH
|
||||||
|
</span> */}
|
||||||
|
<span className={styles.balance}>
|
||||||
|
{/* <strong>{ocn}</strong> OCEAN */}
|
||||||
|
<strong>2474290</strong> OCEAN
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={styles.popoverInfoline}>
|
||||||
|
<Faucet togglePopover={togglePopover} />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className={styles.popoverInfoline}>
|
<div className={styles.popoverInfoline}>
|
||||||
<User.Consumer>
|
<User.Consumer>
|
||||||
{states =>
|
{states =>
|
||||||
@ -22,28 +39,14 @@ const Popover = ({ togglePopover }: { togglePopover: any }) => (
|
|||||||
}
|
}
|
||||||
</User.Consumer>
|
</User.Consumer>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className={styles.popoverInfoline}>
|
<div className={styles.popoverInfoline}>
|
||||||
Network: <strong> Fake Network Name</strong>
|
Fake Network Name
|
||||||
{/* Network:
|
{/*
|
||||||
<User.Consumer>
|
<User.Consumer>
|
||||||
{states => states.network && <strong>{states.network}</strong>}
|
{states => states.network && states.network}
|
||||||
</User.Consumer> */}
|
</User.Consumer> */}
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.popoverInfoline}>
|
|
||||||
<span className={styles.balance} title="Fake data">
|
|
||||||
<strong>30</strong> ETH
|
|
||||||
</span>
|
|
||||||
{/* <span className={styles.balance} title={(eth / 1e18).toFixed(10)}>
|
|
||||||
<strong>{(eth / 1e18).toFixed(3).slice(0, -1)}</strong> ETH
|
|
||||||
</span> */}
|
|
||||||
<span className={styles.balance}>
|
|
||||||
{/* <strong>{ocn}</strong> OCEAN */}
|
|
||||||
<strong>2474290</strong> OCEAN
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div className={styles.popoverInfoline}>
|
|
||||||
<Faucet />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user