Skip to content

Commit

Permalink
Merge pull request #244 from leapdao/fix/222-simple-balance-crash
Browse files Browse the repository at this point in the history
Fix #222 simple balance crash
  • Loading branch information
MaxStalker committed Aug 7, 2019
2 parents f2510d9 + 0e51aa8 commit bdfd3fc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 6 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU"
crossorigin="anonymous"
/>

<link
href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700&display=swap"
rel="stylesheet"
/>

<title>Plasma Burner</title>
<meta name="description" content="Transfer PDAI quickly" />
<meta
Expand Down
5 changes: 3 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export default class App extends Component {

// NOTE: This function is for _displaying_ a currency value to a user. It
// adds a currency unit to the beginning or end of the number!
currencyDisplay(amount, toParts=false, convert=true) {
currencyDisplay(amount, convert=true) {
const { account } = this.state;
const locale = getStoredValue('i18nextLng');
const symbol = getStoredValue('currency', account) || CONFIG.CURRENCY.DEFAULT_CURRENCY;
Expand All @@ -175,7 +175,8 @@ export default class App extends Component {
currency: symbol,
maximumFractionDigits: 2
});
return toParts ? formatter.formatToParts(amount) : formatter.format(amount);

return formatter.format(amount);
}

/*
Expand Down
8 changes: 3 additions & 5 deletions src/components/SimpleBalance.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const StyledBalance = styled.div`
}
span {
font-size: 200%;
font-size: 2.5em;
font-weight: 700;
}
.integer {
Expand Down Expand Up @@ -49,14 +50,11 @@ export default ({ mainAmount, otherAmounts, currencyDisplay }) => {
(acc, curr) => acc + parseInt(curr, 10),
0
);
const parts = currencyDisplay(mainAmount, true);

return (
<>
<StyledBalance>
{parts.map(({ type, value }) => (
<Text.span className={type} key={type}>{value}</Text.span>
))}
<Text.span>{currencyDisplay(mainAmount)}</Text.span>
{otherAssetsTotal > 0 && (
<Text className="otherAssets" italic fontSize={1} textAlign="center">
+{currencyDisplay(otherAssetsTotal)} in other assets
Expand Down

0 comments on commit bdfd3fc

Please sign in to comment.