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
parent
commit
65bd56416d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/components/BalanceSummary/BalanceInfos.js
  2. 7
      src/components/CalculateBalance.js
  3. 6
      static/i18n/en/time.yml

4
src/components/BalanceSummary/BalanceInfos.js

@ -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>
)
}

7
src/components/CalculateBalance.js

@ -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,
}
}

6
static/i18n/en/time.yml

@ -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

Loading…
Cancel
Save