14
14
* limitations under the License.
15
15
*/
16
16
17
+ import { useState , useEffect } from 'react' ;
17
18
import { useTranslation } from 'react-i18next' ;
18
19
import { Link } from 'react-router-dom' ;
19
- import { useState , useEffect , useContext } from 'react' ;
20
20
import { useOnlyVisitableOnMobile } from '@/hooks/onlyvisitableonmobile' ;
21
21
import * as accountApi from '@/api/account' ;
22
22
import { getBalance } from '@/api/account' ;
@@ -27,16 +27,20 @@ import { HideAmountsButton } from '@/components/hideamountsbutton/hideamountsbut
27
27
import { Main , Header } from '@/components/layout' ;
28
28
import { Badge } from '@/components/badge/badge' ;
29
29
import { ChevronRightDark , USBSuccess } from '@/components/icon/icon' ;
30
- import { AppContext } from '@/contexts/AppContext' ;
31
30
import { AllAccountsGuide } from '@/routes/accounts/all-accounts-guide' ;
32
31
import { useMountedRef } from '@/hooks/mount' ;
32
+ import { AmountWithUnit } from '@/components/amount/amount-with-unit' ;
33
33
import styles from './all-accounts.module.css' ;
34
34
35
35
type AllAccountsProps = {
36
36
accounts ?: accountApi . IAccount [ ] ;
37
37
} ;
38
38
39
- const AccountItem = ( { account, hideAmounts } : { account : accountApi . IAccount , hideAmounts : boolean } ) => {
39
+ type TAccountItemProp = {
40
+ account : accountApi . IAccount ;
41
+ } ;
42
+
43
+ const AccountItem = ( { account } : TAccountItemProp ) => {
40
44
const [ balance , setBalance ] = useState < accountApi . TAmountWithConversions > ( ) ;
41
45
const mounted = useMountedRef ( ) ;
42
46
@@ -70,12 +74,7 @@ const AccountItem = ({ account, hideAmounts }: { account: accountApi.IAccount, h
70
74
</ p >
71
75
72
76
< div className = { styles . accountBalanceContainer } >
73
- < div className = { styles . accountBalance } >
74
- { balance ? ( hideAmounts ? '***' : balance . amount ) : '...' }
75
- </ div >
76
- < div className = { styles . coinUnit } >
77
- { balance ? balance . unit : '' }
78
- </ div >
77
+ < AmountWithUnit amount = { balance } />
79
78
</ div >
80
79
< div className = { styles . chevron } >
81
80
< ChevronRightDark />
@@ -84,18 +83,15 @@ const AccountItem = ({ account, hideAmounts }: { account: accountApi.IAccount, h
84
83
) ;
85
84
} ;
86
85
87
-
88
86
/**
89
87
* This component will only be shown on mobile.
90
88
**/
91
89
export const AllAccounts = ( { accounts = [ ] } : AllAccountsProps ) => {
92
90
const { t } = useTranslation ( ) ;
93
- const { hideAmounts } = useContext ( AppContext ) ;
94
91
const accountsByKeystore = getAccountsByKeystore ( accounts ) ;
95
92
useOnlyVisitableOnMobile ( '/settings/manage-accounts' ) ;
96
93
97
94
return (
98
-
99
95
< Main >
100
96
< Header title = { < h2 > { t ( 'settings.accounts' ) } </ h2 > } >
101
97
< HideAmountsButton />
@@ -124,7 +120,7 @@ export const AllAccounts = ({ accounts = [] }: AllAccountsProps) => {
124
120
</ div >
125
121
< div className = { styles . accountsList } >
126
122
{ keystore . accounts . map ( account => (
127
- < AccountItem hideAmounts = { hideAmounts } key = { `account-${ account . code } ` } account = { account } />
123
+ < AccountItem key = { `account-${ account . code } ` } account = { account } />
128
124
) ) }
129
125
</ div >
130
126
</ div >
@@ -134,6 +130,5 @@ export const AllAccounts = ({ accounts = [] }: AllAccountsProps) => {
134
130
</ View >
135
131
< AllAccountsGuide />
136
132
</ Main >
137
-
138
133
) ;
139
134
} ;
0 commit comments