Skip to content

Commit 900432c

Browse files
committed
chore(refactor): refactor payment methods
1 parent e06e027 commit 900432c

File tree

17 files changed

+326
-463
lines changed

17 files changed

+326
-463
lines changed

packages/blockchain-wallet-v4-frontend/src/components/Flyout/model.tsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import React, { ReactElement } from 'react'
22
import { FormattedMessage } from 'react-intl'
3-
import {
4-
CARD_TYPES,
5-
DEFAULT_CARD_SVG_LOGO
6-
} from 'blockchain-wallet-v4-frontend/src/modals/BuySell/PaymentMethods/model'
3+
import { getCardLogo } from 'blockchain-wallet-v4-frontend/src/modals/BuySell/PaymentMethods/model'
74
import { addWeeks, format, isToday } from 'date-fns'
85
import styled, { css } from 'styled-components'
96

@@ -725,17 +722,7 @@ const getIcon = (method: BSPaymentMethodType | undefined, disabled?: boolean): R
725722

726723
switch (method.type) {
727724
case BSPaymentTypes.USER_CARD:
728-
const cardType = CARD_TYPES.find(
729-
(card) => card.type === (method.card ? method.card.type : '')
730-
)
731-
return (
732-
<img
733-
height='18px'
734-
width='auto'
735-
src={cardType ? cardType.logo : DEFAULT_CARD_SVG_LOGO}
736-
alt=''
737-
/>
738-
)
725+
return <img height='18px' width='auto' src={getCardLogo(method.card?.type)} alt='' />
739726
case BSPaymentTypes.FUNDS:
740727
return <Icon size='32px' color='USD' name={method.currency as WalletCurrencyType} />
741728
case BSPaymentTypes.BANK_TRANSFER:

packages/blockchain-wallet-v4-frontend/src/modals/BuySell/LinkedPaymentAccounts/Accounts/index.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import React, { ReactElement, useEffect, useState } from 'react'
22
import { FormattedMessage } from 'react-intl'
3-
import {
4-
CARD_TYPES,
5-
DEFAULT_CARD_SVG_LOGO
6-
} from 'blockchain-wallet-v4-frontend/src/modals/BuySell/PaymentMethods/model'
3+
import { getCardLogo } from 'blockchain-wallet-v4-frontend/src/modals/BuySell/PaymentMethods/model'
74
import { Form, reduxForm } from 'redux-form'
85
import styled from 'styled-components'
96

@@ -176,14 +173,8 @@ const Accounts = (props: Props) => {
176173
if (!card) {
177174
return <></>
178175
}
179-
const cardType = CARD_TYPES.find((cc) => cc.type === card.type)
180176
return (
181-
<img
182-
alt='Credit Card Type'
183-
height='18px'
184-
width='auto'
185-
src={cardType ? cardType.logo : DEFAULT_CARD_SVG_LOGO}
186-
/>
177+
<img alt='Credit Card Type' height='18px' width='auto' src={getCardLogo(card.type)} />
187178
)
188179
case BSPaymentTypes.FUNDS:
189180
return <Icon size='32px' color='USD' name={value.currency as WalletCurrencyType} />

packages/blockchain-wallet-v4-frontend/src/modals/BuySell/PaymentMethods/Methods/ApplePay/index.tsx

Lines changed: 0 additions & 49 deletions
This file was deleted.

packages/blockchain-wallet-v4-frontend/src/modals/BuySell/PaymentMethods/Methods/GooglePay/index.tsx

Lines changed: 0 additions & 49 deletions
This file was deleted.

packages/blockchain-wallet-v4-frontend/src/modals/BuySell/PaymentMethods/Methods/LinkBank/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ const DisplayIconBank = styled(DisplayIcon)`
2323
type Props = {
2424
icon: ReactElement
2525
onClick: (string) => void
26-
text: ReactElement | string
2726
value: BSPaymentMethodType
2827
}
2928

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import React from 'react'
2+
import { FormattedMessage } from 'react-intl'
3+
import styled from 'styled-components'
4+
5+
import { Icon, Image } from 'blockchain-info-components'
6+
import {
7+
Content,
8+
Description,
9+
DisplayContainer,
10+
DisplayIcon,
11+
DisplaySubTitle,
12+
DisplayTitle
13+
} from 'components/BuySell'
14+
15+
const MobileTitle = styled(DisplayTitle)`
16+
margin-bottom: 2px;
17+
`
18+
const MobileIcon = styled(DisplayIcon)`
19+
min-height: 60px;
20+
`
21+
22+
type Props = {
23+
onClick: (string) => void
24+
type: 'apple' | 'google'
25+
}
26+
27+
const MobileMethod = ({ onClick, type }: Props) => {
28+
const capType = type.charAt(0).toUpperCase() + type.slice(1)
29+
return (
30+
<DisplayContainer role='button' onClick={onClick}>
31+
<MobileIcon>
32+
<Image name={`${type}-pay`} height='18px' />
33+
</MobileIcon>
34+
<Content>
35+
<MobileTitle>
36+
<FormattedMessage id={`modals.simplebuy.${type}pay`} defaultMessage={`${capType} Pay`} />
37+
</MobileTitle>
38+
<DisplaySubTitle>
39+
<FormattedMessage id='copy.instantly_available' defaultMessage='Instantly Available' />
40+
</DisplaySubTitle>
41+
<Description>
42+
<FormattedMessage
43+
id={`modals.simplebuy.${type}pay.description`}
44+
defaultMessage={`Simply tap Buy with ${capType} Pay`}
45+
/>
46+
</Description>
47+
</Content>
48+
<Icon name='chevron-right' size='24px' color='grey400' />
49+
</DisplayContainer>
50+
)
51+
}
52+
53+
export default MobileMethod

0 commit comments

Comments
 (0)