-
Notifications
You must be signed in to change notification settings - Fork 504
/
index.tsx
175 lines (163 loc) · 5.02 KB
/
index.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
import { FlyoutWrapper } from 'components/Flyout'
import { Form, InjectedFormProps, reduxForm } from 'redux-form'
import { FormattedMessage } from 'react-intl'
import { Icon, Text } from 'blockchain-info-components'
import { Props as OwnProps, SuccessStateType } from '../index'
import { SBFormPaymentMethod } from 'data/components/simpleBuy/types'
import React, { PureComponent } from 'react'
import styled from 'styled-components'
const Wrapper = styled.div`
display: flex;
justify-content: space-between;
flex-direction: column;
height: 100%;
`
const TopText = styled(Text)`
display: flex;
align-items: center;
margin-bottom: 7px;
`
const PaymentsWrapper = styled.div`
border-top: 1px solid ${props => props.theme.grey000};
`
// const IconContainer = styled.div`
// width: 38px;
// height: 32px;
// border-radius: 16px;
// background-color: ${props => props.theme.blue000};
// display: flex;
// align-items: center;
// justify-content: center;
// `
export type Props = OwnProps & SuccessStateType
class Payments extends PureComponent<InjectedFormProps<{}, Props> & Props> {
getType = (value: SBFormPaymentMethod) => {
switch (value.type) {
case 'BANK_ACCOUNT':
return 'Bank Wire Transfer'
case 'PAYMENT_CARD':
return 'Add a Credit or Debit Card'
case 'USER_CARD':
return value && value.card
? value.card.label
? value.card.label
: value.card.type
: 'Add a Credit or Debit Card'
case 'FUNDS':
return ''
}
}
// getIcon = (value: SBCheckoutFormValuesType): ReactElement => {
// switch (value.type) {
// case 'BANK_ACCOUNT':
// return (
// <IconContainer>
// <Icon size='18px' color='blue600' name='bank-filled' />
// </IconContainer>
// )
// case 'PAYMENT_CARD':
// return (
// <IconContainer>
// <Icon size='16px' color='blue600' name='credit-card-sb' />
// </IconContainer>
// )
// case 'USER_CARD':
// let cardType = CARD_TYPES.find(
// card => card.type === (value.card ? value.card.type : '')
// )
// return (
// <img
// height='18px'
// width='auto'
// src={cardType ? cardType.logo : DEFAULT_CARD_SVG_LOGO}
// />
// )
// case 'FUNDS':
// return <></>
// }
// }
renderElements = () => {
const availableCards = this.props.cards.filter(
card => card.state === 'ACTIVE'
)
const defaultCardMethod = this.props.paymentMethods.methods.find(
m => m.type === 'PAYMENT_CARD'
)
const cardMethods = availableCards.map(card => ({
text: card.card
? card.card.label
? card.card.label
: card.card.type
: 'Credit or Debit Card',
value: {
...card,
type: 'USER_CARD',
limits: defaultCardMethod
? defaultCardMethod.limits
: { min: '1000', max: '500000' }
}
}))
const defaultMethods = this.props.paymentMethods.methods.map(value => ({
text: this.getType(value),
value
}))
// eslint-disable-next-line
console.log('cardMethods', cardMethods)
// eslint-disable-next-line
console.log('availableCards', availableCards)
// eslint-disable-next-line
console.log('defaultMethodsNoFunds', defaultMethods)
// return [
// {
// group: '',
// items: [...cardMethods, ...defaultMethodsNoFunds]
// }
// ]
}
render () {
return (
<Wrapper>
<Form>
<FlyoutWrapper>
<TopText color='grey800' size='20px' weight={600}>
<Icon
cursor
name='arrow-left'
size='20px'
color='grey600'
style={{ marginRight: '24px' }}
role='button'
onClick={() =>
this.props.simpleBuyActions.setStep({
step: 'ENTER_AMOUNT',
fiatCurrency: this.props.fiatCurrency || 'USD',
pair: this.props.pair
})
}
/>
<div style={{ marginLeft: '28px' }}>
<FormattedMessage
id='modals.simplebuy.paymentmethods'
defaultMessage='Payment Methods'
/>
</div>
</TopText>
</FlyoutWrapper>
{this.renderElements()}
<PaymentsWrapper>
<div>
<FormattedMessage
id='modals.simplebuy.depositcash_description'
defaultMessage='Send funds directly from your bank to your Blockchain.com Wallet. Once we receive the manual transfer, use that cash to buy crypto.'
/>
</div>
</PaymentsWrapper>
</Form>
</Wrapper>
)
}
}
export default reduxForm<{}, Props>({
form: 'sbPaymentMethods',
destroyOnUnmount: false
})(Payments)