Skip to content

Commit

Permalink
feat: rendering of payment methods implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
milan-bc committed Jul 17, 2020
1 parent 82b5adc commit e0372fd
Show file tree
Hide file tree
Showing 14 changed files with 218 additions and 84 deletions.
Expand Up @@ -1141,6 +1141,9 @@ type MessagesType = {
'modals.simplebuy.cryptoselect': 'Buy with Cash or Card'
'modals.simplebuy.paymentmethods': 'Payment Methods'
'modals.simplebuy.depositcash_description': 'Send funds directly from your bank to your Blockchain.com Wallet. Once we receive the manual transfer, use that cash to buy crypto.'
'modals.simplebuy.card_limit': '{card} Limit'
'modals.simplebuy.card_expire': 'Exp: {month}/{year}'
'modals.simplebuy.instantly_buy': 'Instantly buy crypto with any Visa or Mastercard.'
'modals.simplebuy.selectcrypto': 'Select the crypto you want to buy.'
'modals.simplebuy.setupaccount': "Next, we'll set up your account."
'modals.simplebuy.success': 'Trade Complete'
Expand Down
Expand Up @@ -409,6 +409,7 @@ const getPayloadObjectForStep = (payload: StepActionsPayload) => {
cryptoCurrency: payload.cryptoCurrency,
defaultMethod: payload.defaultMethod,
fiatCurrency: payload.fiatCurrency,
order: payload.order,
pair: payload.pair
}
case 'ENTER_AMOUNT':
Expand Down
Expand Up @@ -263,7 +263,7 @@ export function simpleBuyReducer (
defaultMethod: action.payload.defaultMethod,
fiatCurrency: action.payload.fiatCurrency,
step: action.payload.step,
order: undefined
order: action.payload.order
}
case '3DS_HANDLER':
case 'CHECKOUT_CONFIRM':
Expand Down
Expand Up @@ -303,6 +303,7 @@ export type StepActionsPayload =
defaultMethod?: SBFormPaymentMethod
fiatCurrency: FiatType
method?: SBFormPaymentMethod
order?: SBOrderType
pair: SBPairType
step: 'ENTER_AMOUNT'
}
Expand All @@ -315,6 +316,7 @@ export type StepActionsPayload =
cryptoCurrency: CoinType
defaultMethod?: SBFormPaymentMethod
fiatCurrency: FiatType
order?: SBOrderType
pair: SBPairType
step: 'PAYMENT_METHODS'
}
Expand Down
@@ -1,5 +1,6 @@
import { actions, selectors } from 'data'
import { bindActionCreators, Dispatch } from 'redux'
import { CoinType, SBPairType } from 'core/types'
import { connect, ConnectedProps } from 'react-redux'
import { getData } from './selectors'
import { Remote } from 'core'
Expand Down Expand Up @@ -49,7 +50,9 @@ const mapDispatchToProps = (dispatch: Dispatch): LinkDispatchPropsType => ({
const connector = connect(mapStateToProps, mapDispatchToProps)

type OwnProps = {
cryptoCurrency?: CoinType
handleClose: () => void
pair: SBPairType
}
type LinkDispatchPropsType = {
simpleBuyActions: typeof actions.components.simpleBuy
Expand Down
Expand Up @@ -65,7 +65,10 @@ const Success: React.FC<InjectedFormProps<{}, Props, ErrorType> &
})
: props.simpleBuyActions.setStep({
fiatCurrency: props.fiatCurrency,
step: 'CRYPTO_SELECTION'
step: 'PAYMENT_METHODS',
pair: props.pair,
cryptoCurrency: props.cryptoCurrency || 'BTC',
order: props.order
})
}
/>
Expand Down
Expand Up @@ -42,7 +42,8 @@ class Checkout extends PureComponent<Props> {
step: 'PAYMENT_METHODS',
fiatCurrency,
pair: this.props.pair,
cryptoCurrency: this.props.cryptoCurrency
cryptoCurrency: this.props.cryptoCurrency,
order: this.props.order
})
} else if (formValues && this.props.method) {
switch (this.props.method.type) {
Expand Down
Expand Up @@ -6,6 +6,7 @@ import {
FiatType,
RemoteDataType,
SBCardType,
SBOrderType,
SBPairType,
SBPaymentMethodsType
} from 'core/types'
Expand Down Expand Up @@ -52,6 +53,7 @@ const connector = connect(mapStateToProps, mapDispatchToProps)
export type OwnProps = {
handleClose: () => void
method: SBFormPaymentMethod
order?: SBOrderType
pair: SBPairType
}
export type SuccessStateType = {
Expand Down
@@ -1,8 +1,7 @@
import { fiatToString } from 'core/exchange/currency'
import { FiatType, SBPaymentMethodType } from 'core/types'
import { FormattedMessage } from 'react-intl'
import { Icon } from 'blockchain-info-components'
import { Title, Value } from 'components/Flyout'
import { SBPaymentMethodType } from 'core/types'
import { Title } from 'components/Flyout'
import React, { ReactElement } from 'react'
import styled from 'styled-components'

Expand All @@ -24,6 +23,7 @@ const Content = styled.div`
display: flex;
flex-direction: column;
width: 100%;
margin-left: 16px;
color: ${props => props.theme.grey800};
`
const DisplayIcon = styled.div`
Expand All @@ -43,18 +43,6 @@ const DisplayTitle = styled(Title)`
color: ${props => props.theme.textBlack};
width: 100%;
`
const MainValue = styled(Value)`
margin-top: 0;
text-align: right;
font-size: 16px;
color: ${props => props.theme.grey900};
`
const SubValue = styled(Value)`
margin-top: 0;
color: ${props => props.theme.textBody};
text-align: right;
font-size: 14px;
`

type Props = {
icon: ReactElement
Expand All @@ -63,7 +51,7 @@ type Props = {
value: SBPaymentMethodType
}

const Payment: React.FC<Props> = ({ value, onClick, icon, text }) => (
const BankAccount: React.FC<Props> = ({ value, onClick, icon, text }) => (
<DisplayContainer
data-e2e={`sb${value.type.toLowerCase()}CurrencySelector`}
role='button'
Expand All @@ -72,29 +60,15 @@ const Payment: React.FC<Props> = ({ value, onClick, icon, text }) => (
<DisplayIcon>{icon}</DisplayIcon>
<Content>
<DisplayTitle>{text}</DisplayTitle>
<MainValue>
{fiatToString({
value: value.limits.max,
unit: String(value.currency) as FiatType
})}
</MainValue>
{value.limits.min && (
<SubValue>
{fiatToString({
value: value.limits.min,
unit: String(value.currency) as FiatType
})}
</SubValue>
)}
{value.type === 'BANK_ACCOUNT' && (
<Title>
<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.'
/>
)}
</Title>
</Content>
<Icon name='chevron-right' size='12px' color='grey400' />
<Icon name='chevron-right' size='24px' color='grey400' />
</DisplayContainer>
)

export default Payment
export default BankAccount
@@ -1,5 +1,6 @@
import { fiatToString } from 'core/exchange/currency'
import { FiatType, SBPaymentMethodType } from 'core/types'
import { FormattedMessage } from 'react-intl'
import { Title, Value } from 'components/Flyout'
import React, { ReactElement } from 'react'
import styled from 'styled-components'
Expand All @@ -17,12 +18,13 @@ const DisplayContainer = styled.div`
background-color: ${props => props.theme.grey100};
}
`
const DisplayMoney = styled.div`
const Display = styled.div`
position: relative;
display: flex;
flex-direction: column;
width: 120px;
width: 230px;
color: ${props => props.theme.grey800};
margin-left: 16px;
`
const DisplayIcon = styled.div`
position: relative;
Expand All @@ -41,6 +43,13 @@ const DisplayTitle = styled(Title)`
color: ${props => props.theme.textBlack};
width: 100%;
`
const DisplaySubTitle = styled(Title)`
align-items: left;
font-weight: 500;
font-size: 14px;
color: ${props => props.theme.textBody};
width: 100%;
`
const MainValue = styled(Value)`
margin-top: 0;
text-align: right;
Expand All @@ -49,11 +58,17 @@ const MainValue = styled(Value)`
`
const SubValue = styled(Value)`
margin-top: 0;
font-weight: 500;
color: ${props => props.theme.textBody};
text-align: right;
font-size: 14px;
`

const DisplayCardDetails = styled.div`
width: 130px;
text-align: right;
`

type Props = {
icon: ReactElement
onClick: (string) => void
Expand All @@ -68,23 +83,36 @@ const Card: React.FC<Props> = ({ value, onClick, icon, text }) => (
onClick={onClick}
>
<DisplayIcon>{icon}</DisplayIcon>
<DisplayTitle>{text}</DisplayTitle>
<DisplayMoney>
<MainValue>
{fiatToString({
value: value.limits.max,
unit: String(value.currency) as FiatType
})}
</MainValue>
{value.limits.min && (
<Display>
<DisplayTitle>{text}</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>
</Display>
{value.card && (
<DisplayCardDetails>
<MainValue>{value.card.number}</MainValue>
<SubValue>
{fiatToString({
value: value.limits.min,
unit: String(value.currency) as FiatType
})}
<FormattedMessage
id='modals.simplebuy.card_expire'
defaultMessage='Exp: {month}/{year}'
values={{
month: value.card.expireMonth,
year: value.card.expireYear
}}
/>
</SubValue>
)}
</DisplayMoney>
</DisplayCardDetails>
)}
</DisplayContainer>
)

Expand Down
@@ -0,0 +1,93 @@
import { fiatToString } from 'core/exchange/currency'
import { FiatType, SBPaymentMethodType } from 'core/types'
import { FormattedMessage } from 'react-intl'
import { Icon } from 'blockchain-info-components'
import { Title } from 'components/Flyout'
import React, { ReactElement } from 'react'
import styled from 'styled-components'

const DisplayContainer = styled.div`
display: flex;
width: 100%;
align-items: center;
box-sizing: border-box;
padding: 16px 40px;
flex-direction: row;
cursor: pointer;
border-bottom: 1px solid ${props => props.theme.grey000};
&hover {
background-color: ${props => props.theme.grey100};
}
`
const Content = styled.div`
position: relative;
display: flex;
flex-direction: column;
color: ${props => props.theme.grey800};
margin-left: 16px;
min-width: 336px;
`
const DisplayIcon = styled.div`
position: relative;
display: flex;
flex-direction: column;
font-size: 16px;
font-weight: 500;
max-width: 32px;
color: ${props => props.theme.grey800};
`
const DisplayTitle = styled(Title)`
align-items: left;
font-weight: 600;
font-size: 16px;
display: flex;
flex-direction: column;
color: ${props => props.theme.textBlack};
width: 100%;
`
const SubTitle = styled(Title)`
color: ${props => props.theme.textBody};
margin-top: 5px;
line-height: 21px;
`

type Props = {
icon: ReactElement
onClick: (string) => void
text: string
value: SBPaymentMethodType
}

const PaymentCard: React.FC<Props> = ({ value, onClick, icon, text }) => (
<DisplayContainer
data-e2e={`sb${value.type.toLowerCase()}CurrencySelector`}
role='button'
onClick={onClick}
>
<DisplayIcon>{icon}</DisplayIcon>
<Content>
<DisplayTitle>{text}</DisplayTitle>
<SubTitle>
<FormattedMessage
id='modals.simplebuy.card_limit'
defaultMessage='{card} Limit'
values={{
card: `${fiatToString({
value: value.limits.max,
unit: String(value.currency) as FiatType
})} ${value.currency}`
}}
/>
</SubTitle>
<SubTitle>
<FormattedMessage
id='modals.simplebuy.instantly_buy'
defaultMessage='Instantly buy crypto with any Visa or Mastercard.'
/>
</SubTitle>
</Content>
<Icon name='chevron-right' size='24px' color='grey400' />
</DisplayContainer>
)

export default PaymentCard

0 comments on commit e0372fd

Please sign in to comment.