WA-230 Adding to UI safe's balance

This commit is contained in:
apanizo 2018-04-17 12:42:33 +02:00
parent c866afcf56
commit 86d3c7c9c4
7 changed files with 70 additions and 15 deletions

View File

@ -4,15 +4,15 @@
}
.soft {
color: #888888;
color: #888888;
}
.medium {
color: #686868;
color: #686868;
}
.dark {
color: black;
color: black;
}
.primary {

View File

@ -6,10 +6,10 @@ import GnoSafe from './Safe'
type Props = SelectorProps
const Layout = ({ safe, provider }: Props) => (
const Layout = ({ safe, balance, provider }: Props) => (
<React.Fragment>
{ safe
? <GnoSafe safe={safe} />
? <GnoSafe safe={safe} balance={balance} />
: <NoSafe provider={provider} text="Not found safe" />
}
</React.Fragment>

View File

@ -14,12 +14,31 @@ const FrameDecorator = story => (
storiesOf('Routes /safe:address', module)
.addDecorator(FrameDecorator)
.add('Safe undefined being connected', () => <Component safe={undefined} provider="METAMASK" />)
.add('Safe undefined NOT connected', () => <Component safe={undefined} provider="" />)
.add('Safe undefined being connected', () => (
<Component
safe={undefined}
provider="METAMASK"
balance="0"
fetchBalance={() => {}}
/>
))
.add('Safe undefined NOT connected', () => (
<Component
safe={undefined}
provider=""
balance="0"
fetchBalance={() => {}}
/>
))
.add('Safe with 2 owners', () => {
const safe = SafeFactory.twoOwnersSafe
return (
<Component safe={safe} provider="METAMASK" />
<Component
safe={safe}
provider="METAMASK"
balance="2"
fetchBalance={() => {}}
/>
)
})

View File

@ -10,9 +10,10 @@ import { type Safe } from '~/routes/safe/store/model/safe'
type SafeProps = {
safe: Safe,
balance: string,
}
const GnoSafe = ({ safe }: SafeProps) => (
const GnoSafe = ({ safe, balance }: SafeProps) => (
<React.Fragment>
<Row>
<Col xs={12}>
@ -21,6 +22,18 @@ const GnoSafe = ({ safe }: SafeProps) => (
</Paragraph>
</Col>
</Row>
<Row>
<Paragraph size="lg">
<Bold>Balance</Bold>
</Paragraph>
</Row>
<Row>
<Block>
<Paragraph>
{balance} - ETH
</Paragraph>
</Block>
</Row>
<Row>
<Paragraph size="lg">
<Bold>Address</Bold>

View File

@ -0,0 +1,10 @@
// @flow
import fetchBalance from '~/routes/safe/store/actions/fetchBalance'
export type Actions = {
fetchBalance: typeof fetchBalance,
}
export default {
fetchBalance,
}

View File

@ -4,19 +4,30 @@ import { connect } from 'react-redux'
import Page from '~/components/layout/Page'
import Layout from '~/routes/safe/component/Layout'
import selector, { type SelectorProps } from './selector'
import actions, { type Actions } from './actions'
type Props = SelectorProps
class SafeView extends React.PureComponent<Actions & SelectorProps> {
componentDidMount() {
const { safe, fetchBalance } = this.props
if (!safe) { return }
const safeAddress: string = safe.get('address')
fetchBalance(safeAddress)
}
class SafeView extends React.PureComponent<Props> {
render() {
const { safe, provider } = this.props
const { safe, provider, balance } = this.props
return (
<Page>
<Layout provider={provider} safe={safe} />
<Layout
balance={balance}
provider={provider}
safe={safe}
/>
</Page>
)
}
}
export default connect(selector)(SafeView)
export default connect(selector, actions)(SafeView)

View File

@ -1,14 +1,16 @@
// @flow
import { createStructuredSelector } from 'reselect'
import { safeSelector, type SafeSelectorProps } from '~/routes/safe/store/selectors'
import { balanceSelector, safeSelector, type SafeSelectorProps } from '~/routes/safe/store/selectors'
import { providerNameSelector } from '~/wallets/store/selectors/index'
export type SelectorProps = {
safe: SafeSelectorProps,
provider: string,
balance: string,
}
export default createStructuredSelector({
safe: safeSelector,
provider: providerNameSelector,
balance: balanceSelector,
})