@@ -8,15 +8,28 @@ import { WalletContext } from "../App";
8
8
import { syncStateWithWallet , triggerRescan } from "../Actions" ;
9
9
import { Button } from "react-bootstrap" ;
10
10
11
- export function Header ( ) {
11
+ import { zatsToZec } from "../../utils" ;
12
12
13
+ export function Header ( ) {
13
14
const { state, dispatch } = useContext ( WalletContext ) ;
14
15
16
+ let activeBalanceReport =
17
+ state . summary ?. account_balances . find (
18
+ ( [ id ] ) => id === state . activeAccount
19
+ ) ;
20
+ console . log ( activeBalanceReport ) ;
21
+
22
+ let totalBalance = activeBalanceReport ? activeBalanceReport [ 1 ] . sapling_balance + activeBalanceReport [ 1 ] . orchard_balance : 0
15
23
return (
16
24
< Stack direction = "horizontal" gap = { 3 } >
17
25
< Form . Select
18
26
value = { state . activeAccount }
19
- onChange = { ( e ) => dispatch ( { type : "set-active-account" , payload : parseInt ( e . target . value ) } ) }
27
+ onChange = { ( e ) =>
28
+ dispatch ( {
29
+ type : "set-active-account" ,
30
+ payload : parseInt ( e . target . value ) ,
31
+ } )
32
+ }
20
33
>
21
34
{ state . summary ?. account_balances . map ( ( [ id ] ) => (
22
35
< option key = { id } value = { id } >
@@ -25,16 +38,31 @@ export function Header() {
25
38
) ) }
26
39
</ Form . Select >
27
40
< Card style = { { width : "30rem" } } >
28
- < Card . Title > Balance: { 0 } ZEC</ Card . Title >
29
- < Card . Text > Available Balance: { 0 } ZEC</ Card . Text >
41
+ < Card . Title > Balance: { zatsToZec ( totalBalance ) } ZEC</ Card . Title >
42
+ < Card . Text > Available Balance: { zatsToZec ( 0 ) } ZEC</ Card . Text >
30
43
</ Card >
31
44
< Card style = { { width : "30rem" } } >
32
- < Card . Text > Chain Height: { state . chainHeight ? "" + state . chainHeight : '?' } </ Card . Text >
33
- < Card . Text > Synced Height: { state . summary ?. fully_scanned_height ? state . summary ?. fully_scanned_height : '?' } </ Card . Text >
45
+ < Card . Text >
46
+ Chain Height: { state . chainHeight ? "" + state . chainHeight : "?" }
47
+ </ Card . Text >
48
+ < Card . Text >
49
+ Synced Height:{ " " }
50
+ { state . summary ?. fully_scanned_height
51
+ ? state . summary ?. fully_scanned_height
52
+ : "?" }
53
+ </ Card . Text >
34
54
</ Card >
35
55
< Stack >
36
- < Button onClick = { async ( ) => await syncStateWithWallet ( state . webWallet , dispatch ) } > Refresh</ Button >
37
- < Button onClick = { ( ) => triggerRescan ( state . webWallet , dispatch ) } > Sync</ Button >
56
+ < Button
57
+ onClick = { async ( ) =>
58
+ await syncStateWithWallet ( state . webWallet , dispatch )
59
+ }
60
+ >
61
+ Refresh
62
+ </ Button >
63
+ < Button onClick = { ( ) => triggerRescan ( state . webWallet , dispatch ) } >
64
+ Sync
65
+ </ Button >
38
66
</ Stack >
39
67
</ Stack >
40
68
) ;
0 commit comments