-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(refactor): linked payments refactor (#6309)
- Loading branch information
1 parent
985bd43
commit 5ef6845
Showing
15 changed files
with
313 additions
and
397 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
...n-wallet-v4-frontend/src/modals/BuySell/LinkedPaymentAccounts/Accounts/AccountsStyles.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import styled from 'styled-components' | ||
|
||
import { Text } from 'blockchain-info-components' | ||
import { FlyoutWrapper } from 'components/Flyout' | ||
|
||
export const Wrapper = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
flex-direction: column; | ||
height: 100vh; | ||
` | ||
export const TopText = styled(Text)` | ||
display: flex; | ||
align-items: center; | ||
margin-bottom: 7px; | ||
` | ||
export const PaymentsWrapper = styled.div` | ||
border-top: 1px solid ${(props) => props.theme.grey000}; | ||
flex-grow: 1; | ||
overflow-y: scroll; | ||
` | ||
export const NoMethods = styled(FlyoutWrapper)` | ||
text-align: center; | ||
` | ||
export const IconContainer = styled.div` | ||
width: 32px; | ||
height: 32px; | ||
border-radius: 50%; | ||
background-color: ${(props) => props.theme.blue000}; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
` |
32 changes: 0 additions & 32 deletions
32
...n-wallet-v4-frontend/src/modals/BuySell/LinkedPaymentAccounts/Accounts/ApplePay/index.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
...-wallet-v4-frontend/src/modals/BuySell/LinkedPaymentAccounts/Accounts/GooglePay/index.tsx
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
...let-v4-frontend/src/modals/BuySell/LinkedPaymentAccounts/Accounts/MobilePayment/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react' | ||
import { FormattedMessage } from 'react-intl' | ||
import styled from 'styled-components' | ||
|
||
import { Image } from 'blockchain-info-components' | ||
import { Content, DisplayContainer, DisplayIcon, DisplayTitle } from 'components/BuySell' | ||
|
||
const MobileDiplayContainer = styled(DisplayContainer)` | ||
height: 74px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
` | ||
|
||
const MobilePayment = ({ onClick, type }: { onClick: () => void; type: 'google' | 'apple' }) => { | ||
const capType = type.charAt(0).toUpperCase() + type.slice(1) | ||
return ( | ||
<MobileDiplayContainer role='button' onClick={onClick}> | ||
<DisplayIcon> | ||
<Image name={`${type}-pay`} height='18px' /> | ||
</DisplayIcon> | ||
<Content> | ||
<DisplayTitle> | ||
<FormattedMessage id={`modals.simplebuy.${type}pay`} defaultMessage={`${capType} Pay`} /> | ||
</DisplayTitle> | ||
</Content> | ||
</MobileDiplayContainer> | ||
) | ||
} | ||
|
||
export default MobilePayment |
103 changes: 103 additions & 0 deletions
103
...ockchain-wallet-v4-frontend/src/modals/BuySell/LinkedPaymentAccounts/Accounts/helpers.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import React, { ReactElement } from 'react' | ||
import { FormattedMessage } from 'react-intl' | ||
|
||
import { BSPaymentMethodType, BSPaymentTypes, WalletCurrencyType } from '@core/types' | ||
import { Icon, Image } from 'blockchain-info-components' | ||
import { getBankLogoImageName } from 'services/images' | ||
|
||
import { CARD_TYPES, DEFAULT_CARD_SVG_LOGO } from '../../PaymentMethods/model' | ||
import { IconContainer } from './AccountsStyles' | ||
|
||
export const getType = (value: BSPaymentMethodType) => { | ||
switch (value.type) { | ||
case BSPaymentTypes.BANK_TRANSFER: | ||
case BSPaymentTypes.LINK_BANK: | ||
return ( | ||
<FormattedMessage | ||
id='modals.simplebuy.easybanktransfer' | ||
defaultMessage='Easy Bank Transfer' | ||
/> | ||
) | ||
case BSPaymentTypes.BANK_ACCOUNT: | ||
return value.currency === 'USD' ? ( | ||
<FormattedMessage id='modals.simplebuy.bankwire' defaultMessage='Wire Transfer' /> | ||
) : ( | ||
<FormattedMessage | ||
id='modals.simplebuy.deposit.regular_bank_transfer' | ||
defaultMessage='Regular Bank Transfer' | ||
/> | ||
) | ||
case BSPaymentTypes.PAYMENT_CARD: | ||
return ( | ||
<FormattedMessage id='modals.simplebuy.paymentcard' defaultMessage='Credit or Debit Card' /> | ||
) | ||
case BSPaymentTypes.USER_CARD: | ||
if (!value?.card) | ||
return ( | ||
<FormattedMessage | ||
id='modals.simplebuy.paymentcard' | ||
defaultMessage='Credit or Debit Card' | ||
/> | ||
) | ||
|
||
return value.card?.label ?? value.card.type | ||
case BSPaymentTypes.FUNDS: | ||
default: | ||
return '' | ||
} | ||
} | ||
|
||
export const getIcon = (value: BSPaymentMethodType): ReactElement => { | ||
switch (value.type) { | ||
case BSPaymentTypes.BANK_TRANSFER: | ||
case BSPaymentTypes.LINK_BANK: | ||
return <Image name='bank' height='48px' /> | ||
case BSPaymentTypes.BANK_ACCOUNT: | ||
return ( | ||
<IconContainer> | ||
<Icon size='18px' color='blue600' name='arrow-down' /> | ||
</IconContainer> | ||
) | ||
case BSPaymentTypes.PAYMENT_CARD: | ||
return ( | ||
<IconContainer> | ||
<Icon size='18px' color='blue600' name='credit-card-sb' /> | ||
</IconContainer> | ||
) | ||
case BSPaymentTypes.USER_CARD: { | ||
const { card } = value | ||
if (!card) { | ||
return <></> | ||
} | ||
const cardType = CARD_TYPES.find((cc) => cc.type === card.type) | ||
return ( | ||
<img | ||
alt='Credit Card Type' | ||
height='18px' | ||
width='auto' | ||
src={cardType?.logo ?? DEFAULT_CARD_SVG_LOGO} | ||
/> | ||
) | ||
} | ||
case BSPaymentTypes.FUNDS: | ||
return <Icon size='32px' color='USD' name={value.currency as WalletCurrencyType} /> | ||
default: | ||
return <Image name='blank-card' /> | ||
} | ||
} | ||
|
||
export const getLinkedBankIcon = (bankName: string): ReactElement => ( | ||
<Image name={getBankLogoImageName(bankName)} height='48px' /> | ||
) | ||
|
||
export const renderBankText = (value: BSPaymentMethodType): string | ReactElement => { | ||
if (value.details) { | ||
return value.details.bankName ?? value.details.accountNumber | ||
} | ||
return <FormattedMessage id='copy.bank_account' defaultMessage='Bank Account' /> | ||
} | ||
|
||
export const renderCardText = ({ card }: BSPaymentMethodType): string => { | ||
if (!card) return 'Credit or Debit Card' | ||
return card.label ?? card.type | ||
} |
1 change: 0 additions & 1 deletion
1
...chain-wallet-v4-frontend/src/modals/BuySell/LinkedPaymentAccounts/Accounts/hooks/index.ts
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
...v4-frontend/src/modals/BuySell/LinkedPaymentAccounts/Accounts/hooks/useCardState/index.ts
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
...tend/src/modals/BuySell/LinkedPaymentAccounts/Accounts/hooks/useCardState/useCardState.ts
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
...rc/modals/BuySell/LinkedPaymentAccounts/Accounts/hooks/useCardState/useCardState.types.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.