This repository has been archived by the owner on Jun 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 299
/
Operation.js
81 lines (71 loc) · 2.29 KB
/
Operation.js
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
// @flow
import React, { PureComponent } from 'react'
import styled from 'styled-components'
import { rgba } from 'styles/helpers'
import Box from 'components/base/Box'
import type { AccountLike, Account, Operation } from '@ledgerhq/live-common/lib/types'
import type { T } from 'types/common'
import {
getAccountCurrency,
getAccountName,
getAccountUnit,
} from '@ledgerhq/live-common/lib/account'
import ConfirmationCell from './ConfirmationCell'
import DateCell from './DateCell'
import AccountCell from './AccountCell'
import AddressCell from './AddressCell'
import AmountCell from './AmountCell'
const OperationRow = styled(Box).attrs(() => ({
horizontal: true,
alignItems: 'center',
}))`
border-bottom: 1px solid ${p => p.theme.colors.palette.divider};
height: 68px;
opacity: ${p => (p.isOptimistic ? 0.5 : 1)};
cursor: pointer;
&:last-child {
border-bottom: 0;
}
&:hover {
background: ${p => rgba(p.theme.colors.wallet, 0.04)};
}
`
type Props = {
operation: Operation,
account: AccountLike,
parentAccount?: Account,
onOperationClick: (operation: Operation, account: AccountLike, parentAccount?: Account) => void,
t: T,
withAccount: boolean,
text?: string,
}
class OperationComponent extends PureComponent<Props> {
static defaultProps = {
withAccount: false,
}
onOperationClick = () => {
const { account, parentAccount, onOperationClick, operation } = this.props
onOperationClick(operation, account, parentAccount)
}
render() {
const { account, parentAccount, t, operation, withAccount, text } = this.props
const isOptimistic = operation.blockHeight === null
const currency = getAccountCurrency(account)
const unit = getAccountUnit(account)
return (
<OperationRow isOptimistic={isOptimistic} onClick={this.onOperationClick}>
<ConfirmationCell
operation={operation}
parentAccount={parentAccount}
account={account}
t={t}
/>
<DateCell text={text} operation={operation} t={t} />
{withAccount && <AccountCell accountName={getAccountName(account)} currency={currency} />}
<AddressCell operation={operation} />
<AmountCell operation={operation} currency={currency} unit={unit} />
</OperationRow>
)
}
}
export default OperationComponent