From 4acb5974015252bc761e7064da369ca9ba385fe0 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Mon, 26 Nov 2018 19:46:45 +0100 Subject: [PATCH] split Summary view into networks --- .../EthereumSummary => ethereum}/Container.js | 0 .../EthereumSummary => ethereum}/index.js | 6 +- .../Wallet/views/Account/Summary/index.js | 26 ++-- .../views/Account/Summary/ripple/Container.js | 45 +++++++ .../views/Account/Summary/ripple/index.js | 114 ++++++++++++++++++ 5 files changed, 172 insertions(+), 19 deletions(-) rename src/views/Wallet/views/Account/Summary/{containers/EthereumSummary => ethereum}/Container.js (100%) rename src/views/Wallet/views/Account/Summary/{containers/EthereumSummary => ethereum}/index.js (96%) create mode 100644 src/views/Wallet/views/Account/Summary/ripple/Container.js create mode 100644 src/views/Wallet/views/Account/Summary/ripple/index.js diff --git a/src/views/Wallet/views/Account/Summary/containers/EthereumSummary/Container.js b/src/views/Wallet/views/Account/Summary/ethereum/Container.js similarity index 100% rename from src/views/Wallet/views/Account/Summary/containers/EthereumSummary/Container.js rename to src/views/Wallet/views/Account/Summary/ethereum/Container.js diff --git a/src/views/Wallet/views/Account/Summary/containers/EthereumSummary/index.js b/src/views/Wallet/views/Account/Summary/ethereum/index.js similarity index 96% rename from src/views/Wallet/views/Account/Summary/containers/EthereumSummary/index.js rename to src/views/Wallet/views/Account/Summary/ethereum/index.js index 0ad14e68..2b55ca61 100644 --- a/src/views/Wallet/views/Account/Summary/containers/EthereumSummary/index.js +++ b/src/views/Wallet/views/Account/Summary/ethereum/index.js @@ -14,9 +14,9 @@ import CoinLogo from 'components/images/CoinLogo'; import * as stateUtils from 'reducers/utils'; import Link from 'components/Link'; import { FONT_WEIGHT, FONT_SIZE } from 'config/variables'; -import AccountBalance from '../../components/Balance'; -import AddedToken from '../../components/Token'; -import AddTokenMessage from '../../components/AddTokenMessage'; +import AccountBalance from '../components/Balance'; +import AddedToken from '../components/Token'; +import AddTokenMessage from '../components/AddTokenMessage'; import type { Props } from './Container'; diff --git a/src/views/Wallet/views/Account/Summary/index.js b/src/views/Wallet/views/Account/Summary/index.js index 4fc7082b..a0a6a5f8 100644 --- a/src/views/Wallet/views/Account/Summary/index.js +++ b/src/views/Wallet/views/Account/Summary/index.js @@ -3,32 +3,26 @@ import React from 'react'; import { connect } from 'react-redux'; import type { State } from 'flowtype'; -import EthereumSummary from './containers/EthereumSummary/Container'; - -type StateProps = { - selectedAccount: $ElementType, - summary: $ElementType, - wallet: $ElementType, - tokens: $ElementType, - fiat: $ElementType, - localStorage: $ElementType, -}; - -export type Props = StateProps; +import EthereumSummary from './ethereum/Container'; +import RippleSummary from './ripple/Container'; type WrapperProps = { selectedAccount: $ElementType, } -// wrapper will return container for requested network type +// return container for requested network type export default connect((state: State): WrapperProps => ({ selectedAccount: state.selectedAccount, }), null)((props) => { const { network } = props.selectedAccount; if (!network) return null; - if (network.type === 'ripple') { - return ; + switch (network.type) { + case 'ethereum': + return ; + case 'ripple': + return ; + default: + return null; } - return ; }); diff --git a/src/views/Wallet/views/Account/Summary/ripple/Container.js b/src/views/Wallet/views/Account/Summary/ripple/Container.js new file mode 100644 index 00000000..18d18175 --- /dev/null +++ b/src/views/Wallet/views/Account/Summary/ripple/Container.js @@ -0,0 +1,45 @@ +/* @flow */ +import { bindActionCreators } from 'redux'; +import { connect } from 'react-redux'; + +import type { MapStateToProps, MapDispatchToProps } from 'react-redux'; +import * as TokenActions from 'actions/TokenActions'; + +import type { State, Dispatch } from 'flowtype'; +import Summary from './index'; + +type OwnProps = { } + +type StateProps = { + selectedAccount: $ElementType, + summary: $ElementType, + wallet: $ElementType, + tokens: $ElementType, + fiat: $ElementType, + localStorage: $ElementType, +}; + +type DispatchProps = { + addToken: typeof TokenActions.add, + loadTokens: typeof TokenActions.load, + removeToken: typeof TokenActions.remove, +} + +export type Props = StateProps & DispatchProps; + +const mapStateToProps: MapStateToProps = (state: State): StateProps => ({ + selectedAccount: state.selectedAccount, + summary: state.summary, + wallet: state.wallet, + tokens: state.tokens, + fiat: state.fiat, + localStorage: state.localStorage, +}); + +const mapDispatchToProps: MapDispatchToProps = (dispatch: Dispatch): DispatchProps => ({ + addToken: bindActionCreators(TokenActions.add, dispatch), + loadTokens: bindActionCreators(TokenActions.load, dispatch), + removeToken: bindActionCreators(TokenActions.remove, dispatch), +}); + +export default connect(mapStateToProps, mapDispatchToProps)(Summary); \ No newline at end of file diff --git a/src/views/Wallet/views/Account/Summary/ripple/index.js b/src/views/Wallet/views/Account/Summary/ripple/index.js new file mode 100644 index 00000000..5f7cf8d2 --- /dev/null +++ b/src/views/Wallet/views/Account/Summary/ripple/index.js @@ -0,0 +1,114 @@ +/* @flow */ +import styled from 'styled-components'; +import React from 'react'; +import { H2 } from 'components/Heading'; +import BigNumber from 'bignumber.js'; +import Icon from 'components/Icon'; +import ICONS from 'config/icons'; +import colors from 'config/colors'; +import Tooltip from 'components/Tooltip'; +import Content from 'views/Wallet/components/Content'; + +import CoinLogo from 'components/images/CoinLogo'; +import * as stateUtils from 'reducers/utils'; +import Link from 'components/Link'; +import { FONT_WEIGHT, FONT_SIZE } from 'config/variables'; +import AccountBalance from '../components/Balance'; + +import type { Props } from './Container'; + +const AccountHeading = styled.div` + padding: 0 0 30px 0; + display: flex; + justify-content: space-between; + align-items: center; +`; + +const H2Wrapper = styled.div` + display: flex; + align-items: center; + padding: 20px 0; +`; + +const StyledTooltip = styled(Tooltip)` + position: relative; + top: 2px; +`; + +const AccountName = styled.div` + display: flex; + justify-content: center; + align-items: center; +`; + +const AccountTitle = styled.div` + font-size: ${FONT_SIZE.WALLET_TITLE}; + font-weight: ${FONT_WEIGHT.BASE}; + color: ${colors.WALLET_TITLE}; +`; + +const StyledCoinLogo = styled(CoinLogo)` + margin-right: 10px; +`; + +const StyledIcon = styled(Icon)` + position: relative; + top: -7px; + &:hover { + cursor: pointer; + } +`; + +const AccountSummary = (props: Props) => { + const device = props.wallet.selectedDevice; + const { + account, + network, + pending, + loader, + shouldRender, + } = props.selectedAccount; + + const { type, title, message } = loader; + + if (!device || !account || !network || !shouldRender) return ; + + const explorerLink: string = `${network.explorer.address}${account.address}`; + const pendingAmount: BigNumber = stateUtils.getPendingAmount(pending, network.symbol); + const balance: string = new BigNumber(account.balance).minus(pendingAmount).toString(10); + + return ( + + + + + + Account #{parseInt(account.index, 10) + 1} + + See full transaction history + + + +

History

+ + + +
+
+
+ ); +}; + +export default AccountSummary; \ No newline at end of file