-
Notifications
You must be signed in to change notification settings - Fork 119
/
AccountDetails.jsx
158 lines (154 loc) · 5.2 KB
/
AccountDetails.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import { FormattedMessage as T } from "react-intl";
import { Tooltip, classNames } from "pi-ui";
import { Balance } from "shared";
import { SlateGrayButton, CopyToClipboardButton } from "buttons";
import { IMPORTED_ACCOUNT, DEFAULT_ACCOUNT } from "constants";
import DataLine from "./DataLine";
import styles from "./AccountDetails.module.css";
const isHidable = (account) =>
account.accountName !== IMPORTED_ACCOUNT &&
account.accountName !== DEFAULT_ACCOUNT &&
!account.total;
const AccountsDetails = ({
account,
showRenameAccount,
hidden,
hideAccount,
showAccount,
showPubKey,
onTogglePubkey,
accountExtendedKey
}) => (
<div key={`details${account.accountNumber}`}>
<div className={styles.columns}>
<div className={styles.columnLeft}>
<div className={styles.title}>
<T id="accounts.balances" m="Balances" />
</div>
<DataLine>
<T id="accounts.total" m="Total" />
<Balance flat amount={account.total} />
</DataLine>
<DataLine>
<T id="accounts.details.spendable" m="Spendable" />
<Balance flat amount={account.spendable} />
</DataLine>
<DataLine>
<T id="accounts.immatureRewards" m="Immature Rewards" />
<Balance flat amount={account.immatureReward} />
</DataLine>
<DataLine>
<T id="accounts.lockedByTickets" m="Locked By Tickets" />
<Balance flat amount={account.lockedByTickets} />
</DataLine>
<DataLine>
<T id="accounts.votingAuthority" m="Voting Authority" />
<Balance flat amount={account.votingAuthority} />
</DataLine>
<DataLine>
<T
id="accounts.immatureStakingRewards"
m="Immature Staking Rewards"
/>
<Balance flat amount={account.immatureStakeGeneration} />
</DataLine>
<DataLine>
<T id="accounts.unconfirmed" m="Unconfirmed" />
<Balance flat amount={account.unconfirmed} />
</DataLine>
</div>
<div className={styles.columnRight}>
<div className={styles.title}>
<T id="accounts.properties" m="Properties" />
</div>
<DataLine>
<T id="accounts.number" m="Account number" />
{account.accountNumber}
</DataLine>
<DataLine>
<T id="accounts.hdPath" m="HD Path" />
{account.HDPath}
</DataLine>
<DataLine>
<T id="accounts.keys" m="Keys" />
<T
id="accounts.keys.counts"
m="{external} external, {internal} internal, {imported} imported"
values={{
external: account.externalKeys,
internal: account.internalKeys,
imported: account.importedKeys
}}
/>
</DataLine>
</div>
</div>
<div className={classNames(styles.actions, styles.isRow)}>
{account.accountName !== IMPORTED_ACCOUNT && (
<div className={styles.pubkey}>
<div className={styles.pubkeyLabel}>
<T id="account.pubKey" m="Extended Public Key" />
</div>
{showPubKey && accountExtendedKey ? (
<>
<div className={styles.pubkeyArea}>{accountExtendedKey}</div>
<CopyToClipboardButton
textToCopy={accountExtendedKey}
className={styles.pubkeyClipboard}
/>
</>
) : (
<SlateGrayButton className={styles.pubkeyButton}>
<T id="account.Hidden" m="Hidden" />
</SlateGrayButton>
)}
</div>
)}
<div className={classNames(styles.buttons, "flex-row")}>
{account.accountName !== IMPORTED_ACCOUNT && (
<Tooltip content={<T id="accounts.rename.tip" m="Rename Account" />}>
<div className={styles.renameButton} onClick={showRenameAccount} />
</Tooltip>
)}
{account.accountName !== IMPORTED_ACCOUNT && (
<Tooltip
content={
showPubKey ? (
<T id="accounts.hide.pubkey" m="Hide Pubkey" />
) : (
<T id="accounts.reveal.pubkey" m="Reveal Pubkey" />
)
}>
<div
className={classNames(
styles.revealPubkeyButton,
showPubKey
? styles.revealPubkeyButtonHide
: styles.revealPubkeyButtonShow
)}
onClick={onTogglePubkey}
/>
</Tooltip>
)}
{isHidable(account) && !hidden && (
<Tooltip content={<T id="accounts.hide.tip" m="Hide" />}>
<div className={styles.hideButton} onClick={hideAccount} />
</Tooltip>
)}
{hidden && (
<Tooltip content={<T id="accounts.show.tip" m="Show" />}>
<div className={styles.showButton} onClick={showAccount} />
</Tooltip>
)}
</div>
</div>
</div>
);
AccountsDetails.propTypes = {
account: PropTypes.object.isRequired,
showRenameAccount: PropTypes.func.isRequired,
hidden: PropTypes.bool.isRequired,
hideAccount: PropTypes.func.isRequired,
showAccount: PropTypes.func.isRequired
};
export default AccountsDetails;