This repository has been archived by the owner on Apr 20, 2020. It is now read-only.
forked from CITA-Toys/CITA-Toys-Wallet
/
TransactionList.tsx
76 lines (74 loc) · 2.45 KB
/
TransactionList.tsx
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
import * as React from 'react'
import { Link } from 'react-router-dom'
import { translate } from 'react-i18next'
import { List, ListItem, ListItemText } from '@material-ui/core'
import { Transaction, TransactionFromServer } from '../../typings/'
const texts = require('../../styles/text.scss')
const styles = require('./styles.scss')
export default translate('microscope')(
({
transactions,
t,
}: {
transactions: TransactionFromServer[]
t: (key: string) => string
}) => (
<List>
{transactions.map(tx => (
<ListItem key={tx.hash} classes={{ root: styles.listItemContainer }}>
<svg className="icon" aria-hidden="true">
<use xlinkHref="#icon-transactionpassword" />
</svg>
<ListItemText
classes={{ primary: styles.primary, root: styles.listItemTextRoot }}
primary={
<React.Fragment>
<span className={texts.ellipsis}>
{t('transaction')}:{' '}
<Link
to={`/transaction/${tx.hash}`}
href={`/transaction/${tx.hash}`}
className={texts.addr}
>
{tx.hash}
</Link>
</span>
<span className={styles.time}>
{tx.timestamp &&
Math.round((Date.now() - +tx.timestamp) / 1000)}s ago
</span>
</React.Fragment>
}
secondary={
<div className={styles.txInfo}>
<div className={texts.ellipsis}>
{t('from')}:{' '}
<Link
to={`/account/${tx.from}`}
href={`/account/${tx.from}`}
className={texts.addr}
>
{tx.from || '_'}
</Link>
</div>
<div className={texts.ellipsis}>
{t('to')}:{' '}
<Link
to={`/account/${tx.to}`}
href={`/account/${tx.to}`}
className={texts.addr}
>
{tx.to || '_'}
</Link>
</div>
<div className={texts.ellipsis}>
{t('value')}: <b className={styles.value}>{tx.value || 0}</b>
</div>
</div>
}
/>
</ListItem>
))}
</List>
),
)