-
Notifications
You must be signed in to change notification settings - Fork 504
/
model.tsx
139 lines (129 loc) · 3.23 KB
/
model.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
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
import { Icon as BCIcon, Text } from 'blockchain-info-components'
import { FormattedMessage } from 'react-intl'
import moment from 'moment'
import React from 'react'
import styled from 'styled-components'
import { CoinTypeEnum } from 'core/types'
import { IconWrapper } from '../components'
import { Props } from '.'
const Icon = styled(BCIcon)`
size: 18px;
font-weight: 600;
`
export const IconTx = (props: Props) => {
switch (props.tx.state) {
case 'COMPLETE':
return (
<IconWrapper color='fiat-light'>
<Icon
size='20px'
color='fiat'
name={props.tx.type === 'DEPOSIT' ? 'arrow-down' : 'arrow-up'}
/>
</IconWrapper>
)
case 'CREATED':
case 'FRAUD_REVIEW':
case 'MANUAL_REVIEW':
case 'PENDING':
case 'PENDING_DEPOSIT':
case 'CLEARED':
return (
<IconWrapper color='grey000'>
<Icon
color='grey600'
size='20px'
name={props.tx.type === 'DEPOSIT' ? 'arrow-down' : 'arrow-up'}
/>
</IconWrapper>
)
case 'FAILED':
case 'REFUNDED':
case 'REJECTED':
case 'UNIDENTIFIED':
return (
<IconWrapper color='red000'>
<Icon
color='red600'
size='20px'
name={props.tx.type === 'DEPOSIT' ? 'arrow-down' : 'arrow-up'}
/>
</IconWrapper>
)
default:
return (
<IconWrapper color='grey000'>
<Icon
size='20px'
weight={500}
color='grey600'
name={'question-in-circle'}
/>
</IconWrapper>
)
}
}
export const Timestamp = (props: Props) => {
const getTimeOrStatus = () => {
switch (props.tx.state) {
case 'COMPLETE':
return moment(props.tx.insertedAt).format('MMM. D, YYYY')
case 'FAILED':
case 'REFUNDED':
case 'REJECTED':
case 'UNIDENTIFIED':
return 'Failed'
case 'MANUAL_REVIEW':
return 'In Review'
default:
return 'In Progress'
}
}
return (
<Text
size='14px'
weight={500}
color='grey600'
style={{ marginTop: '4px' }}
data-e2e='txTimeOrStatus'
>
{getTimeOrStatus()}
</Text>
)
}
export const DepositOrWithdrawal = (props: Props) => {
// if (props.tx.amount.symbol in CoinTypeEnum) {
// return <FormattedMessage id='buttons.transfer' defaultMessage='Transfer' />
// } else {
switch (props.tx.type) {
case 'DEPOSIT':
return <FormattedMessage id='buttons.deposit' defaultMessage='Deposit' />
case 'WITHDRAWAL':
return (
<FormattedMessage id='buttons.withdraw' defaultMessage='Withdraw' />
)
}
// }
}
export const Origin = (props: Props) => {
switch (props.tx.type) {
case 'DEPOSIT':
if (props.tx.amount.symbol in CoinTypeEnum) {
return <>Wallet</>
}
return <>Bank Account</>
case 'WITHDRAWAL':
return <>Trading Wallet</>
}
}
export const Destination = (props: Props) => {
switch (props.tx.type) {
case 'DEPOSIT':
return <>Trading Wallet</>
case 'WITHDRAWAL':
if (props.tx.amount.symbol in CoinTypeEnum) {
return <>Wallet</>
}
return <>Bank Account</>
}
}