From 69a0cb0ef46e4cb7c512eae730580f61d6e5c964 Mon Sep 17 00:00:00 2001 From: meriadec Date: Tue, 6 Mar 2018 10:38:23 +0100 Subject: [PATCH 1/2] Update yarn.lock --- yarn.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yarn.lock b/yarn.lock index 1c79beeb..7904b325 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3482,7 +3482,7 @@ electron-builder-lib@20.2.0, electron-builder-lib@~20.2.0: semver "^5.5.0" temp-file "^3.1.1" -electron-builder@^20.0.4, electron-builder@^20.2.0: +electron-builder@^20.2.0: version "20.2.0" resolved "https://registry.yarnpkg.com/electron-builder/-/electron-builder-20.2.0.tgz#aaeaa439cb96c9a3d7ffda25b28130327c982982" dependencies: @@ -3646,7 +3646,7 @@ electron-webpack@1.13.0: webpack-merge "^4.1.1" yargs "^11.0.0" -electron@1.8.2, electron@^1.8.2: +electron@1.8.2: version "1.8.2" resolved "https://registry.yarnpkg.com/electron/-/electron-1.8.2.tgz#a817cd733c2972b3c7cc4f777caf6e424b88014d" dependencies: From 602ca466e62007cd8b935e04856c3da0c3af0182 Mon Sep 17 00:00:00 2001 From: meriadec Date: Tue, 6 Mar 2018 11:05:27 +0100 Subject: [PATCH 2/2] Fix calculus of diff balance in time --- src/components/AccountPage/index.js | 4 +++- src/components/BalanceSummary/BalanceInfos.js | 9 ++++++--- src/components/BalanceSummary/index.js | 3 ++- src/components/CalculateBalance.js | 11 +++++++---- src/components/DashboardPage/AccountCard.js | 4 ++-- src/components/DashboardPage/index.js | 3 ++- 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/components/AccountPage/index.js b/src/components/AccountPage/index.js index 7ea240ba..5225575a 100644 --- a/src/components/AccountPage/index.js +++ b/src/components/AccountPage/index.js @@ -106,7 +106,7 @@ class AccountPage extends PureComponent { accounts={[account]} selectedTime={selectedTime} daysCount={daysCount} - renderHeader={({ totalBalance, sinceBalance }) => ( + renderHeader={({ totalBalance, sinceBalance, refBalance }) => ( @@ -135,6 +135,7 @@ class AccountPage extends PureComponent { alignItems="center" totalBalance={totalBalance} sinceBalance={sinceBalance} + refBalance={refBalance} since={selectedTime} /> { alignItems="center" totalBalance={totalBalance} sinceBalance={sinceBalance} + refBalance={refBalance} since={selectedTime} /> diff --git a/src/components/BalanceSummary/BalanceInfos.js b/src/components/BalanceSummary/BalanceInfos.js index 1435b3c9..df57bdb9 100644 --- a/src/components/BalanceSummary/BalanceInfos.js +++ b/src/components/BalanceSummary/BalanceInfos.js @@ -22,6 +22,7 @@ type BalanceSinceProps = { since: string, totalBalance: number, sinceBalance: number, + refBalance: number, t: T, } @@ -37,12 +38,12 @@ type Props = { } & BalanceSinceProps export function BalanceSincePercent(props: BalanceSinceProps) { - const { t, totalBalance, sinceBalance, since, ...otherProps } = props + const { t, totalBalance, sinceBalance, refBalance, since, ...otherProps } = props return ( @@ -93,7 +94,7 @@ BalanceTotal.defaultProps = { } function BalanceInfos(props: Props) { - const { t, fiat, totalBalance, since, sinceBalance } = props + const { t, fiat, totalBalance, since, sinceBalance, refBalance } = props return ( @@ -103,6 +104,7 @@ function BalanceInfos(props: Props) { alignItems="flex-end" totalBalance={totalBalance} sinceBalance={sinceBalance} + refBalance={refBalance} since={since} t={t} /> @@ -111,6 +113,7 @@ function BalanceInfos(props: Props) { alignItems="flex-end" totalBalance={totalBalance} sinceBalance={sinceBalance} + refBalance={refBalance} since={since} t={t} /> diff --git a/src/components/BalanceSummary/index.js b/src/components/BalanceSummary/index.js index a42bcd3b..a07eeff8 100644 --- a/src/components/BalanceSummary/index.js +++ b/src/components/BalanceSummary/index.js @@ -36,7 +36,7 @@ const BalanceSummary = ({ ( + render={({ allBalances, totalBalance, sinceBalance, refBalance }) => ( {renderHeader !== null && ( @@ -44,6 +44,7 @@ const BalanceSummary = ({ totalBalance, selectedTime, sinceBalance, + refBalance, })} )} diff --git a/src/components/CalculateBalance.js b/src/components/CalculateBalance.js index 12875371..669d4789 100644 --- a/src/components/CalculateBalance.js +++ b/src/components/CalculateBalance.js @@ -4,6 +4,7 @@ import { PureComponent } from 'react' import { connect } from 'react-redux' import moment from 'moment' import find from 'lodash/find' +import first from 'lodash/first' import last from 'lodash/last' import type { MapStateToProps } from 'react-redux' @@ -31,12 +32,13 @@ function calculateBalance(props) { }).map(e => ({ name: e.date, value: e.balance })) const firstNonEmptyDay = find(allBalances, e => e.value) - const sinceBalance = firstNonEmptyDay ? firstNonEmptyDay.value : 0 + const refBalance = firstNonEmptyDay ? firstNonEmptyDay.value : 0 return { allBalances, totalBalance: last(allBalances).value, - sinceBalance, + sinceBalance: first(allBalances).value, + refBalance, } } @@ -51,6 +53,7 @@ type State = { allBalances: Array, totalBalance: number, sinceBalance: number, + refBalance: number, } class CalculateBalance extends PureComponent { @@ -72,9 +75,9 @@ class CalculateBalance extends PureComponent { render() { const { render } = this.props - const { allBalances, totalBalance, sinceBalance } = this.state + const { allBalances, totalBalance, sinceBalance, refBalance } = this.state - return render({ allBalances, totalBalance, sinceBalance }) + return render({ allBalances, totalBalance, sinceBalance, refBalance }) } } diff --git a/src/components/DashboardPage/AccountCard.js b/src/components/DashboardPage/AccountCard.js index f3c0d658..b55fe56e 100644 --- a/src/components/DashboardPage/AccountCard.js +++ b/src/components/DashboardPage/AccountCard.js @@ -59,7 +59,7 @@ const AccountCard = ({ ( + render={({ allBalances, totalBalance, refBalance }) => ( @@ -75,7 +75,7 @@ const AccountCard = ({ diff --git a/src/components/DashboardPage/index.js b/src/components/DashboardPage/index.js index ae066dbf..81f1c234 100644 --- a/src/components/DashboardPage/index.js +++ b/src/components/DashboardPage/index.js @@ -137,13 +137,14 @@ class DashboardPage extends PureComponent { accounts={accounts} selectedTime={selectedTime} daysCount={daysCount} - renderHeader={({ totalBalance, selectedTime, sinceBalance }) => ( + renderHeader={({ totalBalance, selectedTime, sinceBalance, refBalance }) => ( )} />