diff --git a/src/components/DashboardPage/AccountCard.js b/src/components/DashboardPage/AccountCard.js
deleted file mode 100644
index a9881a2f..00000000
--- a/src/components/DashboardPage/AccountCard.js
+++ /dev/null
@@ -1,103 +0,0 @@
-// @flow
-
-import React, { PureComponent } from 'react'
-import styled from 'styled-components'
-
-import type { Account, Currency } from '@ledgerhq/live-common/lib/types'
-
-import Chart from 'components/base/Chart'
-import Bar from 'components/base/Bar'
-import Box, { Card } from 'components/base/Box'
-import CalculateBalance from 'components/CalculateBalance'
-import FormattedVal from 'components/base/FormattedVal'
-import Ellipsis from 'components/base/Ellipsis'
-import CryptoCurrencyIcon from 'components/CryptoCurrencyIcon'
-import DeltaChange from '../DeltaChange'
-
-const Wrapper = styled(Card).attrs({
- p: 4,
- flex: 1,
-})`
- cursor: ${p => (p.onClick ? 'pointer' : 'default')};
-`
-
-class AccountCard extends PureComponent<{
- counterValue: Currency,
- account: Account,
- onClick?: Account => void,
- daysCount: number,
-}> {
- render() {
- const { counterValue, account, onClick, daysCount, ...props } = this.props
- return (
- onClick(account) : null} {...props}>
-
-
-
-
-
-
-
- {account.currency.name}
-
-
- {account.name}
-
-
-
-
-
-
-
-
-
- {({ isAvailable, balanceHistory, balanceStart, balanceEnd }) => (
-
-
-
- {isAvailable ? (
-
- ) : null}
-
-
- {isAvailable && !balanceStart.isZero() ? (
-
- ) : null}
-
-
-
-
- )}
-
-
- )
- }
-}
-
-export default AccountCard
diff --git a/src/components/DashboardPage/AccountCard/Header.js b/src/components/DashboardPage/AccountCard/Header.js
new file mode 100644
index 00000000..642ec56e
--- /dev/null
+++ b/src/components/DashboardPage/AccountCard/Header.js
@@ -0,0 +1,33 @@
+// @flow
+
+import React, { PureComponent } from 'react'
+import type { CryptoCurrency } from '@ledgerhq/live-common/lib/types'
+import Box from 'components/base/Box'
+import Ellipsis from 'components/base/Ellipsis'
+import CryptoCurrencyIcon from 'components/CryptoCurrencyIcon'
+
+class AccountCardHeader extends PureComponent<{
+ currency: CryptoCurrency,
+ accountName: string,
+}> {
+ render() {
+ const { currency, accountName } = this.props
+ return (
+
+
+
+
+
+
+ {currency.name}
+
+
+ {accountName}
+
+
+
+ )
+ }
+}
+
+export default AccountCardHeader
diff --git a/src/components/DashboardPage/AccountCard/index.js b/src/components/DashboardPage/AccountCard/index.js
new file mode 100644
index 00000000..25dc16d4
--- /dev/null
+++ b/src/components/DashboardPage/AccountCard/index.js
@@ -0,0 +1,94 @@
+// @flow
+
+import React, { PureComponent } from 'react'
+import styled from 'styled-components'
+
+import type { Account, Currency } from '@ledgerhq/live-common/lib/types'
+
+import Chart from 'components/base/Chart'
+import Bar from 'components/base/Bar'
+import Box, { Card } from 'components/base/Box'
+import CalculateBalance from 'components/CalculateBalance'
+import FormattedVal from 'components/base/FormattedVal'
+import DeltaChange from 'components/DeltaChange'
+import AccountCardHeader from './Header'
+
+const Wrapper = styled(Card).attrs({
+ p: 4,
+ flex: 1,
+})`
+ cursor: ${p => (p.onClick ? 'pointer' : 'default')};
+`
+
+class AccountCard extends PureComponent<{
+ counterValue: Currency,
+ account: Account,
+ onClick: Account => void,
+ daysCount: number,
+}> {
+ renderBody = ({ isAvailable, balanceHistory, balanceStart, balanceEnd }: *) => {
+ const { counterValue, account } = this.props
+ return (
+
+
+
+ {isAvailable ? (
+
+ ) : null}
+
+
+ {isAvailable && !balanceStart.isZero() ? (
+
+ ) : null}
+
+
+
+
+ )
+ }
+ onClick = () => {
+ const { account, onClick } = this.props
+ onClick(account)
+ }
+ render() {
+ const { counterValue, account, onClick, daysCount, ...props } = this.props
+ return (
+
+
+
+
+
+
+
+
+
+ {this.renderBody}
+
+
+ )
+ }
+}
+
+export default AccountCard
diff --git a/src/components/DashboardPage/AccountCardList.js b/src/components/DashboardPage/AccountCardList.js
new file mode 100644
index 00000000..eee7321e
--- /dev/null
+++ b/src/components/DashboardPage/AccountCardList.js
@@ -0,0 +1,66 @@
+// @flow
+
+import React, { Component } from 'react'
+import type { Account, Currency } from '@ledgerhq/live-common/lib/types'
+
+import Box from 'components/base/Box'
+import AccountCard from './AccountCard'
+import AccountCardListHeader from './AccountCardListHeader'
+import AccountCardPlaceholder from './AccountCardPlaceholder'
+
+type Props = {
+ accounts: Account[],
+ onAccountClick: Account => void,
+ counterValue: Currency,
+ daysCount: number,
+}
+
+class AccountCardList extends Component {
+ render() {
+ const { accounts, counterValue, daysCount, onAccountClick } = this.props
+
+ return (
+
+
+
+ {accounts
+ .map(account => ({
+ key: account.id,
+ account,
+ }))
+ .concat(
+ Array(3 - (accounts.length % 3))
+ .fill(null)
+ .map((_, i) => ({
+ key: `placeholder_${i}`,
+ withPlaceholder: i === 0,
+ })),
+ )
+ .map(item => (
+
+ {item.account ? (
+
+ ) : item.withPlaceholder ? (
+
+ ) : null}
+
+ ))}
+
+
+ )
+ }
+}
+
+export default AccountCardList
diff --git a/src/components/DashboardPage/AccountCardListHeader.js b/src/components/DashboardPage/AccountCardListHeader.js
new file mode 100644
index 00000000..9da0fde5
--- /dev/null
+++ b/src/components/DashboardPage/AccountCardListHeader.js
@@ -0,0 +1,33 @@
+// @flow
+
+import React, { PureComponent } from 'react'
+import { translate } from 'react-i18next'
+import type { T } from 'types/common'
+
+import Box from 'components/base/Box'
+import Text from 'components/base/Text'
+import AccountsOrder from './AccountsOrder'
+
+type Props = {
+ t: T,
+ accountsLength: number,
+}
+
+class AccountCardListHeader extends PureComponent {
+ render() {
+ const { accountsLength, t } = this.props
+
+ return (
+
+
+ {t('app:dashboard.accounts.title', { count: accountsLength })}
+
+
+
+
+
+ )
+ }
+}
+
+export default translate()(AccountCardListHeader)
diff --git a/src/components/DashboardPage/AccountCardPlaceholder.js b/src/components/DashboardPage/AccountCardPlaceholder.js
new file mode 100644
index 00000000..1936fe4d
--- /dev/null
+++ b/src/components/DashboardPage/AccountCardPlaceholder.js
@@ -0,0 +1,64 @@
+// @flow
+
+import React, { PureComponent } from 'react'
+import { connect } from 'react-redux'
+import { translate } from 'react-i18next'
+import styled from 'styled-components'
+
+import { openModal } from 'reducers/modals'
+import { MODAL_ADD_ACCOUNTS } from 'config/constants'
+import type { T } from 'types/common'
+import { i } from 'helpers/staticPath'
+import Box from 'components/base/Box'
+import Button from 'components/base/Button'
+
+const Wrapper = styled(Box).attrs({
+ p: 4,
+ flex: 1,
+ alignItems: 'center',
+})`
+ border: 1px dashed ${p => p.theme.colors.fog};
+ border-radius: 4px;
+ height: 215px;
+`
+
+class AccountCardPlaceholder extends PureComponent<{
+ t: T,
+ openModal: string => void,
+}> {
+ onAddAccounts = () => this.props.openModal(MODAL_ADD_ACCOUNTS)
+
+ render() {
+ const { t } = this.props
+ return (
+
+
+
+
+
+ {t('app:dashboard.emptyAccountTile.desc')}
+
+
+
+ )
+ }
+}
+
+export default translate()(
+ connect(
+ null,
+ {
+ openModal,
+ },
+ )(AccountCardPlaceholder),
+)
diff --git a/src/components/DashboardPage/CurrentGreetings.js b/src/components/DashboardPage/CurrentGreetings.js
new file mode 100644
index 00000000..da4896b8
--- /dev/null
+++ b/src/components/DashboardPage/CurrentGreetings.js
@@ -0,0 +1,31 @@
+// @flow
+import React, { PureComponent } from 'react'
+import { translate } from 'react-i18next'
+import type { T } from 'types/common'
+
+import Text from 'components/base/Text'
+
+const getCurrentGreetings = () => {
+ const localTimeHour = new Date().getHours()
+ const afternoon_breakpoint = 12
+ const evening_breakpoint = 17
+ if (localTimeHour >= afternoon_breakpoint && localTimeHour < evening_breakpoint) {
+ return 'app:dashboard.greeting.afternoon'
+ } else if (localTimeHour >= evening_breakpoint) {
+ return 'app:dashboard.greeting.evening'
+ }
+ return 'app:dashboard.greeting.morning'
+}
+
+class CurrentGettings extends PureComponent<{ t: T }> {
+ render() {
+ const { t } = this.props
+ return (
+
+ {t(getCurrentGreetings())}
+
+ )
+ }
+}
+
+export default translate()(CurrentGettings)
diff --git a/src/components/DashboardPage/SummaryDesc.js b/src/components/DashboardPage/SummaryDesc.js
new file mode 100644
index 00000000..ff8c5f3e
--- /dev/null
+++ b/src/components/DashboardPage/SummaryDesc.js
@@ -0,0 +1,22 @@
+// @flow
+
+import React, { PureComponent } from 'react'
+import { translate } from 'react-i18next'
+import type { T } from 'types/common'
+import Text from 'components/base/Text'
+
+class SummaryDesc extends PureComponent<{
+ t: T,
+ totalAccounts: number,
+}> {
+ render() {
+ const { totalAccounts, t } = this.props
+ return (
+
+ {t('app:dashboard.summary', { count: totalAccounts })}
+
+ )
+ }
+}
+
+export default translate()(SummaryDesc)
diff --git a/src/components/DashboardPage/index.js b/src/components/DashboardPage/index.js
index 384f6d71..2b3b6340 100644
--- a/src/components/DashboardPage/index.js
+++ b/src/components/DashboardPage/index.js
@@ -5,7 +5,6 @@ import uniq from 'lodash/uniq'
import { compose } from 'redux'
import { translate } from 'react-i18next'
import { connect } from 'react-redux'
-import styled from 'styled-components'
import { push } from 'react-router-redux'
import { createStructuredSelector } from 'reselect'
import type { Account, Currency } from '@ledgerhq/live-common/lib/types'
@@ -14,11 +13,8 @@ import type { T } from 'types/common'
import { colors } from 'styles/theme'
import { accountsSelector } from 'reducers/accounts'
-import { openModal } from 'reducers/modals'
-import { MODAL_ADD_ACCOUNTS } from 'config/constants'
import {
counterValueCurrencySelector,
- localeSelector,
selectedTimeRangeSelector,
timeRangeDaysByKey,
} from 'reducers/settings'
@@ -32,27 +28,23 @@ import UpdateNotifier from 'components/UpdateNotifier'
import BalanceInfos from 'components/BalanceSummary/BalanceInfos'
import BalanceSummary from 'components/BalanceSummary'
import Box from 'components/base/Box'
-import { i } from 'helpers/staticPath'
import PillsDaysCount from 'components/PillsDaysCount'
-import Text from 'components/base/Text'
import OperationsList from 'components/OperationsList'
import StickyBackToTop from 'components/StickyBackToTop'
-import Button from 'components/base/Button'
-import AccountCard from './AccountCard'
-import AccountsOrder from './AccountsOrder'
import EmptyState from './EmptyState'
+import CurrentGreetings from './CurrentGreetings'
+import SummaryDesc from './SummaryDesc'
+import AccountCardList from './AccountCardList'
const mapStateToProps = createStructuredSelector({
accounts: accountsSelector,
counterValue: counterValueCurrencySelector,
- locale: localeSelector,
selectedTimeRange: selectedTimeRangeSelector,
})
const mapDispatchToProps = {
push,
saveSettings,
- openModal,
}
type Props = {
@@ -62,41 +54,33 @@ type Props = {
counterValue: Currency,
selectedTimeRange: TimeRange,
saveSettings: ({ selectedTimeRange: TimeRange }) => *,
- openModal: string => void,
}
class DashboardPage extends PureComponent {
onAccountClick = account => this.props.push(`/account/${account.id}`)
- handleGreeting = () => {
- const localTimeHour = new Date().getHours()
- const afternoon_breakpoint = 12
- const evening_breakpoint = 17
-
- if (localTimeHour >= afternoon_breakpoint && localTimeHour < evening_breakpoint) {
- return 'app:dashboard.greeting.afternoon'
- } else if (localTimeHour >= evening_breakpoint) {
- return 'app:dashboard.greeting.evening'
- }
- return 'app:dashboard.greeting.morning'
- }
-
handleChangeSelectedTime = item => {
this.props.saveSettings({ selectedTimeRange: item.key })
}
- _cacheBalance = null
+ renderHeader = ({ isAvailable, totalBalance, selectedTimeRange, sinceBalance, refBalance }) => (
+
+ )
render() {
- const { accounts, t, counterValue, selectedTimeRange, openModal } = this.props
+ const { accounts, t, counterValue, selectedTimeRange } = this.props
const daysCount = timeRangeDaysByKey[selectedTimeRange]
- const timeFrame = this.handleGreeting()
- const imagePath = i('empty-account-tile.svg')
const totalAccounts = accounts.length
const totalCurrencies = uniq(accounts.map(a => a.currency.id)).length
const totalOperations = accounts.reduce((sum, a) => sum + a.operations.length, 0)
- const displayOperationsHelper = (account: Account) => account.operations.length > 0
- const displayOperations = accounts.some(displayOperationsHelper)
return (
@@ -113,12 +97,8 @@ class DashboardPage extends PureComponent {
-
- {t(timeFrame)}
-
-
- {t('app:dashboard.summary', { count: totalAccounts })}
-
+
+
{
/>
-
-
+
+
+
+ {totalOperations > 0 && (
+ (
-
- )}
+ title={t('app:dashboard.recentActivity')}
+ withAccount
/>
-
-
-
- {t('app:dashboard.accounts.title', { count: accounts.length })}
-
-
-
-
-
-
- {accounts
- .concat(
- Array(3 - (accounts.length % 3))
- .fill(null)
- .map((_, i) => i === 0),
- )
- .map((account, i) => (
-
- {account ? (
- typeof account === 'object' ? (
-
- ) : (
-
-
-
-
-
- {t('app:dashboard.emptyAccountTile.desc')}
-
-
-
- )
- ) : null}
-
- ))}
-
-
- {displayOperations && (
-
- )}
-
-
+ )}
+
) : (
@@ -243,13 +151,3 @@ export default compose(
),
translate(),
)(DashboardPage)
-
-const Wrapper = styled(Box).attrs({
- p: 4,
- flex: 1,
- alignItems: 'center',
-})`
- border: 1px dashed ${p => p.theme.colors.fog};
- border-radius: 4px;
- height: 215px;
-`