Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implemented select payment and render payments
- Loading branch information
Showing
9 changed files
with
250 additions
and
82 deletions.
There are no files selected for viewing
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
148 changes: 148 additions & 0 deletions
148
...blockchain-wallet-v4-frontend/src/modals/SimpleBuy/EnterAmount/Checkout/Payment/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,148 @@ | ||
import { | ||
CARD_TYPES, | ||
DEFAULT_CARD_SVG_LOGO | ||
} from 'components/Form/CreditCardBox/model' | ||
import { fiatToString } from 'core/exchange/currency' | ||
import { FiatType } from 'core/types' | ||
import { FormattedMessage } from 'react-intl' | ||
import { Icon, Text } from 'blockchain-info-components' | ||
import { Props } from '..' | ||
import { SBFormPaymentMethod } from 'data/components/simpleBuy/types' | ||
import { Title } from 'components/Flyout' | ||
import React, { ReactElement } from 'react' | ||
import styled from 'styled-components' | ||
|
||
const PaymentContainer = styled.div` | ||
border: 1px solid ${props => props.theme.grey100}; | ||
box-sizing: border-box; | ||
width: 400px; | ||
height: 80px; | ||
border-radius: 8px; | ||
margin-bottom: 24px; | ||
display: flex; | ||
flex-direction: row; | ||
cursor: pointer; | ||
padding: 12px 28px; | ||
justify-content: space-between; | ||
` | ||
|
||
const DisplayIcon = styled.div` | ||
position: relative; | ||
display: flex; | ||
flex-direction: column; | ||
font-weight: 500; | ||
justify-content: center; | ||
color: ${props => props.theme.grey800}; | ||
` | ||
const PaymentText = styled(Text)` | ||
width: 285px; | ||
justify-content: center; | ||
display: flex; | ||
flex-direction: column; | ||
padding-left: 16px; | ||
` | ||
const PaymentArrowContainer = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
` | ||
const DisplayTitle = styled(Title)` | ||
align-items: left; | ||
font-weight: 600; | ||
display: flex; | ||
flex-direction: column; | ||
line-height: 24px; | ||
color: ${props => props.theme.textBlack}; | ||
width: 100%; | ||
` | ||
const DisplaySubTitle = styled(Title)` | ||
align-items: left; | ||
font-weight: 500; | ||
font-size: 12px; | ||
line-height: 24px; | ||
color: ${props => props.theme.textBody}; | ||
width: 100%; | ||
` | ||
|
||
const renderCardText = (value: SBFormPaymentMethod): string => { | ||
return value.card | ||
? value.card.label | ||
? value.card.label | ||
: value.card.type | ||
: 'Credit or Debit Card' | ||
} | ||
|
||
const renderCard = (value: SBFormPaymentMethod) => ( | ||
<> | ||
<DisplayTitle>{renderCardText(value)}</DisplayTitle> | ||
<DisplaySubTitle> | ||
<FormattedMessage | ||
id='modals.simplebuy.card_limit' | ||
defaultMessage='{card} Limit' | ||
values={{ | ||
card: `${fiatToString({ | ||
value: value.limits.max, | ||
unit: String(value.currency) as FiatType | ||
})} ${value.currency}` | ||
}} | ||
/> | ||
</DisplaySubTitle> | ||
</> | ||
) | ||
|
||
const renderFund = (value: SBFormPaymentMethod) => ( | ||
<> | ||
<DisplayTitle>{value.currency}</DisplayTitle> | ||
<DisplaySubTitle> | ||
{fiatToString({ | ||
value: value.limits.max, | ||
unit: String(value.currency) as FiatType | ||
})} | ||
</DisplaySubTitle> | ||
</> | ||
) | ||
|
||
const getIcon = (value: SBFormPaymentMethod): ReactElement => { | ||
switch (value.type) { | ||
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 <></> | ||
default: | ||
return <></> | ||
} | ||
} | ||
|
||
const Payment: React.FC<Props> = props => ( | ||
<PaymentContainer | ||
onClick={() => | ||
props.simpleBuyActions.setStep({ | ||
step: 'PAYMENT_METHODS', | ||
pair: props.pair, | ||
fiatCurrency: props.fiatCurrency || 'USD', | ||
cryptoCurrency: props.cryptoCurrency | ||
}) | ||
} | ||
> | ||
<DisplayIcon>{getIcon(props.method)}</DisplayIcon> | ||
<PaymentText> | ||
{props.method.type === 'USER_CARD' | ||
? renderCard(props.method) | ||
: renderFund(props.method)} | ||
</PaymentText> | ||
<PaymentArrowContainer> | ||
<Icon cursor name='arrow-right' size='20px' color='grey600' /> | ||
</PaymentArrowContainer> | ||
</PaymentContainer> | ||
) | ||
|
||
export default Payment |
67 changes: 67 additions & 0 deletions
67
...hain-wallet-v4-frontend/src/modals/SimpleBuy/EnterAmount/Checkout/SelectPayment/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,67 @@ | ||
import { FormattedMessage } from 'react-intl' | ||
import { Icon, Text } from 'blockchain-info-components' | ||
import { Props } from '..' | ||
import React from 'react' | ||
import styled from 'styled-components' | ||
|
||
const SelectPaymentContainer = styled.div` | ||
border: 1px solid ${props => props.theme.grey100}; | ||
box-sizing: border-box; | ||
width: 400px; | ||
height: 80px; | ||
border-radius: 8px; | ||
margin-bottom: 24px; | ||
display: flex; | ||
flex-direction: row; | ||
cursor: pointer; | ||
padding: 23px 28px 28px 28px; | ||
line-height: 32px; | ||
justify-content: space-between; | ||
` | ||
|
||
const SelectIconWrapper = styled.div` | ||
background-color: ${props => props.theme.blue000}; | ||
width: 32px; | ||
height: 32px; | ||
border-radius: 50%; | ||
margin-right: 22px; | ||
` | ||
const SelectPaymentText = styled(Text)` | ||
width: 285px; | ||
font-style: normal; | ||
font-weight: 600; | ||
font-size: 14px; | ||
line-height: 32px; | ||
` | ||
|
||
const SelectPayment: React.FC<Props> = props => ( | ||
<SelectPaymentContainer | ||
onClick={() => | ||
props.simpleBuyActions.setStep({ | ||
step: 'PAYMENT_METHODS', | ||
pair: props.pair, | ||
fiatCurrency: props.fiatCurrency || 'USD', | ||
cryptoCurrency: props.cryptoCurrency | ||
}) | ||
} | ||
> | ||
<SelectIconWrapper> | ||
<Icon | ||
cursor | ||
name='plus-in-circle-filled' | ||
size='22px' | ||
color='blue600' | ||
style={{ marginLeft: '4px' }} | ||
/> | ||
</SelectIconWrapper> | ||
<SelectPaymentText> | ||
<FormattedMessage | ||
id='modals.simplebuy.confirm.jump_to_payment' | ||
defaultMessage='Select Cash or Card' | ||
/> | ||
</SelectPaymentText> | ||
<Icon cursor name='arrow-right' size='20px' color='grey600' /> | ||
</SelectPaymentContainer> | ||
) | ||
|
||
export default SelectPayment |
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
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
Oops, something went wrong.