|
1 | 1 | import React, { useEffect, useState } from 'react' |
2 | | -import { Table, Grid, Button } from 'semantic-ui-react' |
| 2 | +import { Table, Grid, Button, Label } from 'semantic-ui-react' |
3 | 3 | import { CopyToClipboard } from 'react-copy-to-clipboard' |
4 | 4 | import { useSubstrateState } from './substrate-lib' |
5 | 5 |
|
@@ -34,48 +34,54 @@ export default function Main(props) { |
34 | 34 | return ( |
35 | 35 | <Grid.Column> |
36 | 36 | <h1>Balances</h1> |
37 | | - <Table celled striped size="small"> |
38 | | - <Table.Body> |
39 | | - <Table.Row> |
40 | | - <Table.Cell width={3} textAlign="right"> |
41 | | - <strong>Name</strong> |
42 | | - </Table.Cell> |
43 | | - <Table.Cell width={10}> |
44 | | - <strong>Address</strong> |
45 | | - </Table.Cell> |
46 | | - <Table.Cell width={3}> |
47 | | - <strong>Balance</strong> |
48 | | - </Table.Cell> |
49 | | - </Table.Row> |
50 | | - {accounts.map(account => ( |
51 | | - <Table.Row key={account.address}> |
| 37 | + {accounts.length === 0 ? ( |
| 38 | + <Label basic color="yellow"> |
| 39 | + No accounts to be shown |
| 40 | + </Label> |
| 41 | + ) : ( |
| 42 | + <Table celled striped size="small"> |
| 43 | + <Table.Body> |
| 44 | + <Table.Row> |
52 | 45 | <Table.Cell width={3} textAlign="right"> |
53 | | - {account.meta.name} |
| 46 | + <strong>Name</strong> |
54 | 47 | </Table.Cell> |
55 | 48 | <Table.Cell width={10}> |
56 | | - <span style={{ display: 'inline-block', minWidth: '31em' }}> |
57 | | - {account.address} |
58 | | - </span> |
59 | | - <CopyToClipboard text={account.address}> |
60 | | - <Button |
61 | | - basic |
62 | | - circular |
63 | | - compact |
64 | | - size="mini" |
65 | | - color="blue" |
66 | | - icon="copy outline" |
67 | | - /> |
68 | | - </CopyToClipboard> |
| 49 | + <strong>Address</strong> |
69 | 50 | </Table.Cell> |
70 | 51 | <Table.Cell width={3}> |
71 | | - {balances && |
72 | | - balances[account.address] && |
73 | | - balances[account.address]} |
| 52 | + <strong>Balance</strong> |
74 | 53 | </Table.Cell> |
75 | 54 | </Table.Row> |
76 | | - ))} |
77 | | - </Table.Body> |
78 | | - </Table> |
| 55 | + {accounts.map(account => ( |
| 56 | + <Table.Row key={account.address}> |
| 57 | + <Table.Cell width={3} textAlign="right"> |
| 58 | + {account.meta.name} |
| 59 | + </Table.Cell> |
| 60 | + <Table.Cell width={10}> |
| 61 | + <span style={{ display: 'inline-block', minWidth: '31em' }}> |
| 62 | + {account.address} |
| 63 | + </span> |
| 64 | + <CopyToClipboard text={account.address}> |
| 65 | + <Button |
| 66 | + basic |
| 67 | + circular |
| 68 | + compact |
| 69 | + size="mini" |
| 70 | + color="blue" |
| 71 | + icon="copy outline" |
| 72 | + /> |
| 73 | + </CopyToClipboard> |
| 74 | + </Table.Cell> |
| 75 | + <Table.Cell width={3}> |
| 76 | + {balances && |
| 77 | + balances[account.address] && |
| 78 | + balances[account.address]} |
| 79 | + </Table.Cell> |
| 80 | + </Table.Row> |
| 81 | + ))} |
| 82 | + </Table.Body> |
| 83 | + </Table> |
| 84 | + )} |
79 | 85 | </Grid.Column> |
80 | 86 | ) |
81 | 87 | } |
0 commit comments