Skip to content

Commit

Permalink
fix(interest): add btc balance
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLeoB committed May 27, 2020
1 parent 3b36076 commit 3911f95
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
Wrapper
} from './model'

import { Exchange } from 'core'
import { LinkDispatchPropsType, OwnProps, SuccessStateType } from '.'

const AccountSummary: React.FC<Props> = props => {
Expand All @@ -46,6 +47,21 @@ const AccountSummary: React.FC<Props> = props => {
const account = accountBalances && accountBalances[coin]
const lockupPeriod = interestLimits[coin].lockUpDuration / 86400

const accountBalanceStandard =
account &&
Exchange.convertCoinToCoin({
value: account.balance || 0,
coin: 'BTC',
baseToStandard: true
}).value

const interestBalanceStandard =
account &&
Exchange.convertCoinToCoin({
value: account.totalInterest || 0,
coin: 'BTC',
baseToStandard: true
}).value
return (
<Wrapper>
<Top>
Expand Down Expand Up @@ -73,34 +89,74 @@ const AccountSummary: React.FC<Props> = props => {
</TopText>
<Row>
<Container>
<Text color='grey600' size='14px' weight={500}>
<Text
color='grey600'
size='14px'
weight={500}
style={{ marginBottom: '5px' }}
>
<FormattedMessage
id='modals.interest.detailsbalance'
defaultMessage='Your {coin} Balance'
values={{ coin }}
/>
</Text>
{account ? (
<FiatDisplay color='grey800' size='20px' weight={600} coin={coin}>
{account.balance}
</FiatDisplay>
<>
<FiatDisplay
color='grey800'
size='20px'
weight={600}
coin={coin}
>
{account.balance}
</FiatDisplay>
<Text
color='grey600'
size='14px'
weight={500}
style={{ marginTop: '5px' }}
>
{accountBalanceStandard} {coin}
</Text>
</>
) : (
<FiatDisplay color='grey800' size='20px' weight={600} coin={coin}>
0
</FiatDisplay>
)}
</Container>
<Container>
<Text color='grey600' size='14px' weight={500}>
<Text
color='grey600'
size='14px'
weight={500}
style={{ marginBottom: '5px' }}
>
<FormattedMessage
id='modals.interest.totalearned'
defaultMessage='Total Interest Earned'
/>
</Text>
{account ? (
<FiatDisplay color='grey800' size='20px' weight={600} coin={coin}>
{account.totalInterest}
</FiatDisplay>
<>
<FiatDisplay
color='grey800'
size='20px'
weight={600}
coin={coin}
>
{account.totalInterest}
</FiatDisplay>
<Text
color='grey600'
size='14px'
weight={500}
style={{ marginTop: '5px' }}
>
{interestBalanceStandard} {coin}
</Text>
</>
) : (
<FiatDisplay color='grey800' size='20px' weight={600} coin={coin}>
0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ function SummaryCard (props: OwnProps & SuccessStateType): ReactElement {
}).value
const totalInterest =
interestAccountBalance.BTC && interestAccountBalance.BTC.totalInterest
const totalInterestStandard = Exchange.convertCoinToCoin({
value: totalInterest || 0,
coin: 'BTC',
baseToStandard: true
}).value
return (
<DepositBox showInterestInfoBox={showInterestInfoBox}>
<Row>
Expand Down Expand Up @@ -146,6 +151,17 @@ function SummaryCard (props: OwnProps & SuccessStateType): ReactElement {
>
{balanceStandard} {coinTicker}
</Text>
<Text
size='12px'
weight={500}
style={{ lineHeight: '1.5', marginTop: '5px' }}
>
<FormattedMessage
id='modals.interest.detailsbalance'
defaultMessage='Your {coin} Balance'
values={{ coin }}
/>
</Text>
</AmountColumn>
<AmountColumn>
<FiatDisplay
Expand All @@ -159,7 +175,19 @@ function SummaryCard (props: OwnProps & SuccessStateType): ReactElement {
>
{totalInterest}
</FiatDisplay>
<Text size='12px' weight={500} style={{ lineHeight: '1.5' }}>
<Text
data-e2e='btcInterest'
size='12px'
weight={500}
style={{ lineHeight: '1.5' }}
>
{totalInterestStandard} {coinTicker}
</Text>
<Text
size='12px'
weight={500}
style={{ lineHeight: '1.5', marginTop: '5px' }}
>
<FormattedMessage
id='scenes.interest.summarycard.totalinterest'
defaultMessage='Total Interest Earned'
Expand Down

0 comments on commit 3911f95

Please sign in to comment.