Browse Source
Merge pull request #191 from meriadec/master
Prevent Infinity % display, and update translation
master
Loëck Vézien
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
12 additions and
5 deletions
-
src/components/BalanceSummary/BalanceInfos.js
-
src/components/CalculateBalance.js
-
static/i18n/en/time.yml
|
|
@ -46,7 +46,7 @@ export function BalanceSincePercent(props: BalanceSinceProps) { |
|
|
|
alwaysShowSign |
|
|
|
fontSize={7} |
|
|
|
/> |
|
|
|
<Sub>{t('time:since', { since: t(`time:${since}`) })}</Sub> |
|
|
|
<Sub>{t(`time:since.${since}`)}</Sub> |
|
|
|
</Box> |
|
|
|
) |
|
|
|
} |
|
|
@ -62,7 +62,7 @@ export function BalanceSinceDiff(props: Props) { |
|
|
|
val={totalBalance - sinceBalance} |
|
|
|
fontSize={7} |
|
|
|
/> |
|
|
|
<Sub>{t('time:since', { since: t(`time:${since}`) })}</Sub> |
|
|
|
<Sub>{t(`time:since.${since}`)}</Sub> |
|
|
|
</Box> |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
@ -3,7 +3,7 @@ |
|
|
|
import { PureComponent } from 'react' |
|
|
|
import { connect } from 'react-redux' |
|
|
|
import moment from 'moment' |
|
|
|
import first from 'lodash/first' |
|
|
|
import find from 'lodash/find' |
|
|
|
import last from 'lodash/last' |
|
|
|
|
|
|
|
import type { MapStateToProps } from 'react-redux' |
|
|
@ -30,10 +30,13 @@ function calculateBalance(props) { |
|
|
|
interval, |
|
|
|
}).map(e => ({ name: e.date, value: e.balance })) |
|
|
|
|
|
|
|
const firstNonEmptyDay = find(allBalances, e => e.value) |
|
|
|
const sinceBalance = firstNonEmptyDay ? firstNonEmptyDay.value : 0 |
|
|
|
|
|
|
|
return { |
|
|
|
allBalances, |
|
|
|
totalBalance: last(allBalances).value, |
|
|
|
sinceBalance: first(allBalances).value, |
|
|
|
sinceBalance, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -3,4 +3,8 @@ week: Week |
|
|
|
month: Month |
|
|
|
year: Year |
|
|
|
|
|
|
|
since: since one {{since}} |
|
|
|
since: |
|
|
|
day: since a day |
|
|
|
week: since a week |
|
|
|
month: since a month |
|
|
|
year: since a year |
|
|
|