mirror of
https://github.com/trezor/trezor-wallet
synced 2025-01-08 07:01:04 +00:00
show balance in local currency
This commit is contained in:
parent
d269f31af9
commit
e54c1befb2
@ -15,6 +15,7 @@ type Props = {
|
|||||||
network: Network,
|
network: Network,
|
||||||
balance: string,
|
balance: string,
|
||||||
fiat: $ElementType<ReducersState, 'fiat'>,
|
fiat: $ElementType<ReducersState, 'fiat'>,
|
||||||
|
localCurrency: string,
|
||||||
};
|
};
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
@ -59,6 +60,7 @@ const FiatValue = styled.div`
|
|||||||
min-height: 25px;
|
min-height: 25px;
|
||||||
color: ${colors.TEXT_PRIMARY};
|
color: ${colors.TEXT_PRIMARY};
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
text-transform: uppercase;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const FiatValueRate = styled.div`
|
const FiatValueRate = styled.div`
|
||||||
@ -69,6 +71,7 @@ const FiatValueRate = styled.div`
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
color: ${colors.TEXT_PRIMARY};
|
color: ${colors.TEXT_PRIMARY};
|
||||||
|
text-transform: uppercase;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const BalanceWrapper = styled.div`
|
const BalanceWrapper = styled.div`
|
||||||
@ -116,14 +119,14 @@ class AccountBalance extends PureComponent<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { network } = this.props;
|
const { network, localCurrency } = this.props;
|
||||||
const fiatRate = this.props.fiat.find(f => f.network === network.shortcut);
|
const fiatRate = this.props.fiat.find(f => f.network === network.shortcut);
|
||||||
let accountBalance = '';
|
let accountBalance = '';
|
||||||
let fiatRateValue = '';
|
let fiatRateValue = '';
|
||||||
let fiat = '';
|
let fiat = '';
|
||||||
if (fiatRate) {
|
if (fiatRate) {
|
||||||
accountBalance = new BigNumber(this.props.balance);
|
accountBalance = new BigNumber(this.props.balance);
|
||||||
fiatRateValue = new BigNumber(fiatRate.value).toFixed(2);
|
fiatRateValue = new BigNumber(fiatRate.rates[localCurrency]).toFixed(2);
|
||||||
fiat = accountBalance.times(fiatRateValue).toFixed(2);
|
fiat = accountBalance.times(fiatRateValue).toFixed(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +158,9 @@ class AccountBalance extends PureComponent<Props, State> {
|
|||||||
<FormattedMessage {...l10nMessages.TR_BALANCE} />
|
<FormattedMessage {...l10nMessages.TR_BALANCE} />
|
||||||
</Label>
|
</Label>
|
||||||
<TooltipWrapper>
|
<TooltipWrapper>
|
||||||
<FiatValue>{fiatRate ? `$ ${fiat}` : 'N/A'}</FiatValue>
|
<FiatValue>
|
||||||
|
{fiatRate ? `${fiat} ${localCurrency}` : 'N/A'}
|
||||||
|
</FiatValue>
|
||||||
{!fiatRate && NoRatesTooltip}
|
{!fiatRate && NoRatesTooltip}
|
||||||
</TooltipWrapper>
|
</TooltipWrapper>
|
||||||
<CoinBalance>
|
<CoinBalance>
|
||||||
@ -168,7 +173,7 @@ class AccountBalance extends PureComponent<Props, State> {
|
|||||||
</Label>
|
</Label>
|
||||||
<TooltipWrapper>
|
<TooltipWrapper>
|
||||||
<FiatValueRate>
|
<FiatValueRate>
|
||||||
{fiatRate ? `$ ${fiatRateValue}` : 'N/A'}
|
{fiatRate ? `${fiatRateValue} ${localCurrency}` : 'N/A'}
|
||||||
</FiatValueRate>
|
</FiatValueRate>
|
||||||
{!fiatRate && NoRatesTooltip}
|
{!fiatRate && NoRatesTooltip}
|
||||||
</TooltipWrapper>
|
</TooltipWrapper>
|
||||||
|
@ -100,7 +100,12 @@ const AccountSummary = (props: Props) => {
|
|||||||
/>
|
/>
|
||||||
</Link>
|
</Link>
|
||||||
</AccountHeading>
|
</AccountHeading>
|
||||||
<AccountBalance network={network} balance={balance} fiat={props.fiat} />
|
<AccountBalance
|
||||||
|
network={network}
|
||||||
|
balance={balance}
|
||||||
|
fiat={props.fiat}
|
||||||
|
localCurrency={props.wallet.localCurrency}
|
||||||
|
/>
|
||||||
<H2Wrapper>
|
<H2Wrapper>
|
||||||
<H2>
|
<H2>
|
||||||
<FormattedMessage {...l10nSummaryMessages.TR_TOKENS} />
|
<FormattedMessage {...l10nSummaryMessages.TR_TOKENS} />
|
||||||
|
@ -14,6 +14,7 @@ type Props = {
|
|||||||
balance: string,
|
balance: string,
|
||||||
reserve: string,
|
reserve: string,
|
||||||
fiat: $ElementType<ReducersState, 'fiat'>,
|
fiat: $ElementType<ReducersState, 'fiat'>,
|
||||||
|
localCurrency: string,
|
||||||
};
|
};
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
@ -58,6 +59,7 @@ const FiatValue = styled.div`
|
|||||||
min-height: 25px;
|
min-height: 25px;
|
||||||
color: ${colors.TEXT_PRIMARY};
|
color: ${colors.TEXT_PRIMARY};
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
text-transform: uppercase;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const FiatValueRate = styled.div`
|
const FiatValueRate = styled.div`
|
||||||
@ -68,6 +70,7 @@ const FiatValueRate = styled.div`
|
|||||||
display: flex;
|
display: flex;
|
||||||
color: ${colors.TEXT_PRIMARY};
|
color: ${colors.TEXT_PRIMARY};
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
text-transform: uppercase;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const BalanceWrapper = styled.div`
|
const BalanceWrapper = styled.div`
|
||||||
@ -115,14 +118,14 @@ class AccountBalance extends PureComponent<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { network } = this.props;
|
const { network, localCurrency } = this.props;
|
||||||
const fiatRate = this.props.fiat.find(f => f.network === network.shortcut);
|
const fiatRate = this.props.fiat.find(f => f.network === network.shortcut);
|
||||||
let accountBalance = '';
|
let accountBalance = '';
|
||||||
let fiatRateValue = '';
|
let fiatRateValue = '';
|
||||||
let fiat = '';
|
let fiat = '';
|
||||||
if (fiatRate) {
|
if (fiatRate) {
|
||||||
accountBalance = new BigNumber(this.props.balance);
|
accountBalance = new BigNumber(this.props.balance);
|
||||||
fiatRateValue = new BigNumber(fiatRate.value).toFixed(2);
|
fiatRateValue = new BigNumber(fiatRate.rates[localCurrency]).toFixed(2);
|
||||||
fiat = accountBalance.times(fiatRateValue).toFixed(2);
|
fiat = accountBalance.times(fiatRateValue).toFixed(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +155,9 @@ class AccountBalance extends PureComponent<Props, State> {
|
|||||||
<BalanceWrapper>
|
<BalanceWrapper>
|
||||||
<Label>Balance</Label>
|
<Label>Balance</Label>
|
||||||
<TooltipWrapper>
|
<TooltipWrapper>
|
||||||
<FiatValue>{fiatRate ? `$ ${fiat}` : 'N/A'}</FiatValue>
|
<FiatValue>
|
||||||
|
{fiatRate ? `${fiat} ${localCurrency}` : 'N/A'}
|
||||||
|
</FiatValue>
|
||||||
{!fiatRate && NoRatesTooltip}
|
{!fiatRate && NoRatesTooltip}
|
||||||
</TooltipWrapper>
|
</TooltipWrapper>
|
||||||
<CoinBalance>
|
<CoinBalance>
|
||||||
@ -172,7 +177,7 @@ class AccountBalance extends PureComponent<Props, State> {
|
|||||||
<Label>Rate</Label>
|
<Label>Rate</Label>
|
||||||
<TooltipWrapper>
|
<TooltipWrapper>
|
||||||
<FiatValueRate>
|
<FiatValueRate>
|
||||||
{fiatRate ? `$ ${fiatRateValue}` : 'N/A'}
|
{fiatRate ? `${fiatRateValue} ${localCurrency}` : 'N/A'}
|
||||||
</FiatValueRate>
|
</FiatValueRate>
|
||||||
{!fiatRate && NoRatesTooltip}
|
{!fiatRate && NoRatesTooltip}
|
||||||
</TooltipWrapper>
|
</TooltipWrapper>
|
||||||
|
@ -85,6 +85,7 @@ const AccountSummary = (props: Props) => {
|
|||||||
balance={balance}
|
balance={balance}
|
||||||
reserve={reserve}
|
reserve={reserve}
|
||||||
fiat={props.fiat}
|
fiat={props.fiat}
|
||||||
|
localCurrency={props.wallet.localCurrency}
|
||||||
/>
|
/>
|
||||||
{TMP_SHOW_HISTORY && (
|
{TMP_SHOW_HISTORY && (
|
||||||
<H2Wrapper>
|
<H2Wrapper>
|
||||||
|
Loading…
Reference in New Issue
Block a user