From da7fe35a602c9f196f2bf28a722885865c4cf029 Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Fri, 2 Apr 2021 13:50:51 -0700 Subject: [PATCH] temp commit: beginning balance and transactions page --- .../src/js/components/lib/balance.js | 95 +++++++++++++++++++ .../src/js/components/lib/header.js | 51 ++++++++++ .../src/js/components/lib/transactions.js | 35 +++++++ pkg/btc-wallet/src/js/components/root.js | 8 +- 4 files changed, 184 insertions(+), 5 deletions(-) create mode 100644 pkg/btc-wallet/src/js/components/lib/balance.js create mode 100644 pkg/btc-wallet/src/js/components/lib/header.js create mode 100644 pkg/btc-wallet/src/js/components/lib/transactions.js diff --git a/pkg/btc-wallet/src/js/components/lib/balance.js b/pkg/btc-wallet/src/js/components/lib/balance.js new file mode 100644 index 0000000000..c0b975b178 --- /dev/null +++ b/pkg/btc-wallet/src/js/components/lib/balance.js @@ -0,0 +1,95 @@ +import React, { Component } from 'react'; +import { + Box, + Icon, + Row, + Text, + Button, + Col, +} from '@tlon/indigo-react'; + +function currencyFormat(sats, conversion, denomination) { + let val; + let text; + switch (denomination) { + case "USD": + case "CAD": + val = sats * 0.00000001 * conversion[denomination] + text = '$' + val.toFixed(2).replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,') + break; + case "BTC": + val = sats * 0.00000001; + text = 'BTC ' + val; + break; + default: + break; + } + return text; +} + +export default class Balance extends Component { + constructor(props) { + super(props); + + this.state = { + conversion: { + USD: 50000, + CAD: 70000, + BTC: 1, + }, + denomination: "CAD", + } + } + + + render() { + const sats = this.props.state.wallet.balance || 0; + const value = currencyFormat(sats, this.state.conversion, this.state.denomination); + + return ( + + + Balance + bc1qxy...hx0wlh + + + {this.state.denomination} + + + + {value} + {sats} sats + + +