Skip to content

Commit

Permalink
feat: deposit screen implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
milan-bc committed Jul 22, 2020
1 parent 6c6e569 commit 32c827d
Show file tree
Hide file tree
Showing 18 changed files with 412 additions and 313 deletions.
Expand Up @@ -1121,6 +1121,14 @@ type MessagesType = {
'modals.simplebuy.confirm.rate': 'Exchange Rate'
'modals.simplebuy.confirm.total': 'Total'
'modals.simplebuy.doing.work': 'Doing Work...'
'modals.simplebuy.deposit.bank_transfer': 'Bank Transfer'
'modals.simplebuy.deposit.bank_transfer_only': 'Bank Transfers Only'
'modals.simplebuy.deposit.bank_transfer_only_description': 'Only send funds from a bank account in your name. If not, your deposit could be delayed or rejected.'
'modals.simplebuy.deposit.processing_time': 'Processing Time'
'modals.simplebuy.deposit.processing_time.info.eur': 'Funds will be credited to your EUR wallet as soon as we receive them. SEPA transfers usually take around 1 business day to reach us.'
'modals.simplebuy.deposit.processing_time.info.gbp': 'Funds will be credited to your GBP wallet as soon as we receive them. In the UK Faster Payments Network, this can take a couple of hours.'
'modals.simplebuy.deposit.title': 'Deposit {currency}'
'modals.simplebuy.deposit.terms_and_condition': 'Deposit {currency}'
'modals.simplebuy.eligible.failure': 'Oops. Something went wrong on our side. Please try again.'
'modals.simplebuy.eligible.tryagain': 'Try Again'
'modals.simplebuy.error': 'Trade Failed'
Expand Down
@@ -0,0 +1,58 @@
import * as C from 'services/AlertService'
import { actions } from 'data'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import CopyClipboard from './template'
import React from 'react'

interface CopyToClipboardProps {
address: string
alertActions: any
}

interface CopyToClipboardState {
active: boolean
}

class CopyToClipboardContainer extends React.PureComponent<
CopyToClipboardProps,
CopyToClipboardState
> {
constructor (props) {
super(props)
this.timeout = undefined
this.state = { active: false }
this.handleClick = this.handleClick.bind(this)
}

componentWillUnmount () {
clearTimeout(this.timeout)
}
timeout: number | undefined

handleClick () {
const { alertActions } = this.props
this.setState({ active: true })
this.timeout = setTimeout(() => {
this.setState({ active: false })
}, 2000)
alertActions.displaySuccess(C.COPY_LINK_CLIPBOARD_SUCCESS)
}

render () {
return (
<CopyClipboard
active={this.state.active}
address={this.props.address}
handleClick={this.handleClick}
data-e2e={this.props['data-e2e']}
/>
)
}
}

const mapDispatchToProps = dispatch => ({
alertActions: bindActionCreators(actions.alerts, dispatch)
})

export default connect(null, mapDispatchToProps)(CopyToClipboardContainer)
@@ -0,0 +1,50 @@
import { IconButton } from 'blockchain-info-components'
import CopyToClipBoard from 'react-copy-to-clipboard'
import React from 'react'
import styled from 'styled-components'

interface CopyButtonProps {
active: boolean
}

const CopyButton = styled(IconButton)<CopyButtonProps>`
width: 30px;
min-width: 0;
height: 30px;
border: none;
background: transparent;
&:hover {
border: none;
background: transparent;
}
> span {
margin-top: ${props => (props.active ? '-2px' : '-5px;')};
margin-right: 0 !important;
font-size: ${props => (props.active ? '18px' : '20px')};
color: ${props =>
props.active ? props.theme['success'] : props.theme.grey400};
}
`

interface CopyClipboardProps {
active: boolean
address: string
handleClick: () => void
}

const CopyClipboard = (props: CopyClipboardProps) => {
const { active, address, handleClick } = props

return (
<CopyToClipBoard text={address} onCopy={handleClick}>
<CopyButton
active={active}
name={active ? 'check' : 'copy-clipboard'}
color='grey100'
data-e2e='copyClipboardCopyButton'
/>
</CopyToClipBoard>
)
}

export default CopyClipboard
Expand Up @@ -104,6 +104,7 @@ export const Row = styled.div`
border-bottom: 1px solid ${props => props.theme.grey000};
}
`

export const Title = styled(Text)`
font-size: 14px;
font-weight: 500;
Expand Down
@@ -0,0 +1,12 @@
import { Title } from 'components/Flyout'
import styled from 'styled-components'

const DisplaySubTitle = styled(Title)`
align-items: left;
font-weight: 500;
font-size: 14px;
color: ${props => props.theme.grey600};
width: 100%;
`

export default DisplaySubTitle
@@ -0,0 +1,12 @@
import styled from 'styled-components'

const MultiRowContainer = styled.div`
position: relative;
display: flex;
flex-direction: column;
width: 230px;
color: ${props => props.theme.grey800};
margin-left: 16px;
`

export default MultiRowContainer
@@ -1,6 +1,15 @@
import Content from './Content'
import DisplayContainer from './DisplayContainer'
import DisplayIcon from './DisplayIcon'
import DisplaySubTitle from './DisplaySubTitle'
import DisplayTitle from './DisplayTitle'
import MultiRowContainer from './MultiRowContainer'

export { DisplayIcon, DisplayContainer, Content, DisplayTitle }
export {
DisplayIcon,
DisplayContainer,
Content,
DisplayTitle,
DisplaySubTitle,
MultiRowContainer
}
Expand Up @@ -427,8 +427,12 @@ const getPayloadObjectForStep = (payload: StepActionsPayload) => {
cryptoCurrency: payload.cryptoCurrency,
fiatCurrency: payload.fiatCurrency
}
case 'CHECKOUT_CONFIRM':
case 'TRANSFER_DETAILS':
return {
step: payload.step,
fiatCurrency: payload.fiatCurrency
}
case 'CHECKOUT_CONFIRM':
case 'ORDER_SUMMARY':
case 'CANCEL_ORDER':
return { step: payload.step, order: payload.order }
Expand Down
Expand Up @@ -268,13 +268,18 @@ export function simpleBuyReducer (
case '3DS_HANDLER':
case 'CHECKOUT_CONFIRM':
case 'ORDER_SUMMARY':
case 'TRANSFER_DETAILS':
case 'CANCEL_ORDER':
return {
...state,
order: action.payload.order,
step: action.payload.step
}
case 'TRANSFER_DETAILS':
return {
...state,
step: action.payload.step,
fiatCurrency: action.payload.fiatCurrency
}
default: {
return {
...state,
Expand Down
Expand Up @@ -8,7 +8,6 @@ import {
CoinTypeEnum,
Everypay3DSResponseType,
FiatEligibleType,
FiatType,
SBAccountType,
SBCardStateType,
SBCardType,
Expand Down Expand Up @@ -242,9 +241,7 @@ export default ({
const order = S.getSBOrder(yield select())
if (!order) throw new Error('NO_ORDER_EXISTS_TO_CONFIRM')
yield put(actions.form.startSubmit('sbCheckoutConfirm'))
const confirmedOrder: SBOrderType = yield call(api.confirmSBOrder, order)
yield put(actions.form.stopSubmit('sbCheckoutConfirm'))
yield put(A.setStep({ step: 'TRANSFER_DETAILS', order: confirmedOrder }))
yield put(A.fetchSBOrders())
} catch (e) {
const error = errorHandler(e)
Expand Down Expand Up @@ -436,10 +433,7 @@ export default ({
const fetchSBPaymentAccount = function * () {
try {
yield put(A.fetchSBPaymentAccountLoading())
const order = S.getSBOrder(yield select())
const fiatCurrency: FiatType | false = order
? (order.pair.split('-')[1] as FiatType)
: false
const fiatCurrency = S.getFiatCurrency(yield select())
if (!fiatCurrency) throw new Error(NO_FIAT_CURRENCY)
const account: SBAccountType = yield call(
api.getSBPaymentAccount,
Expand Down
Expand Up @@ -286,11 +286,7 @@ interface FetchSBSuggestedAmountsSuccess {
export type StepActionsPayload =
| {
order: SBOrderType
step:
| 'CHECKOUT_CONFIRM'
| 'TRANSFER_DETAILS'
| 'ORDER_SUMMARY'
| 'CANCEL_ORDER'
step: 'CHECKOUT_CONFIRM' | 'ORDER_SUMMARY' | 'CANCEL_ORDER'
}
| {
cryptoCurrency?: CoinType
Expand All @@ -306,6 +302,10 @@ export type StepActionsPayload =
fiatCurrency: FiatType
step: 'CRYPTO_SELECTION'
}
| {
fiatCurrency: FiatType
step: 'TRANSFER_DETAILS'
}
| {
cryptoCurrency: CoinType
defaultMethod?: SBPaymentMethodType
Expand Down
Expand Up @@ -93,7 +93,7 @@ const Success: React.FC<Props> = props => {
<div style={{ margin: '16px 0' }}>
<Status {...props} />
</div>
{props.order.state === 'PENDING_DEPOSIT' &&
{/* {props.order.state === 'PENDING_DEPOSIT' &&
!props.order.paymentMethodId && (
<Button
fullwidth
Expand All @@ -104,7 +104,7 @@ const Success: React.FC<Props> = props => {
onClick={() =>
props.simpleBuyActions.setStep({
step: 'TRANSFER_DETAILS',
order: props.order
fiatCurrency: props.fiatCurrency
})
}
>
Expand All @@ -113,7 +113,7 @@ const Success: React.FC<Props> = props => {
defaultMessage='View Bank Transfer Details'
/>
</Button>
)}
)} */}
</FlyoutWrapper>
<Row>
<Title color='grey600' size='14px' weight={500}>
Expand Down
Expand Up @@ -2,31 +2,17 @@ import { convertBaseToStandard } from 'data/components/exchange/services'
import {
DisplayContainer,
DisplayIcon,
DisplayTitle
DisplaySubTitle,
DisplayTitle,
MultiRowContainer
} from 'components/SimpleBuy'
import { fiatToString } from 'core/exchange/currency'
import { FiatType, SBPaymentMethodType } from 'core/types'
import { FormattedMessage } from 'react-intl'
import { Title, Value } from 'components/Flyout'
import { Value } from 'components/Flyout'
import React, { ReactElement } from 'react'
import styled from 'styled-components'

const Display = styled.div`
position: relative;
display: flex;
flex-direction: column;
width: 230px;
color: ${props => props.theme.grey800};
margin-left: 16px;
`

const DisplaySubTitle = styled(Title)`
align-items: left;
font-weight: 500;
font-size: 14px;
color: ${props => props.theme.grey600};
width: 100%;
`
const MainValue = styled(Value)`
margin-top: 0;
text-align: right;
Expand Down Expand Up @@ -60,7 +46,7 @@ const Card: React.FC<Props> = ({ value, onClick, icon, text }) => (
onClick={onClick}
>
<DisplayIcon>{icon}</DisplayIcon>
<Display>
<MultiRowContainer>
<DisplayTitle>{text}</DisplayTitle>
<DisplaySubTitle>
<FormattedMessage
Expand All @@ -74,7 +60,7 @@ const Card: React.FC<Props> = ({ value, onClick, icon, text }) => (
}}
/>
</DisplaySubTitle>
</Display>
</MultiRowContainer>
{value.card && (
<DisplayCardDetails>
<MainValue>{value.card.number}</MainValue>
Expand Down
Expand Up @@ -2,11 +2,14 @@ import { convertBaseToStandard } from 'data/components/exchange/services'
import {
DisplayContainer,
DisplayIcon,
DisplayTitle
DisplaySubTitle,
DisplayTitle,
MultiRowContainer
} from 'components/SimpleBuy'
import { fiatToString } from 'core/exchange/currency'
import { FiatType, SBPaymentMethodType } from 'core/types'
import { Value } from 'components/Flyout'
import Currencies from 'blockchain-wallet-v4/src/exchange/currencies'
import React, { ReactElement } from 'react'
import styled from 'styled-components'

Expand Down Expand Up @@ -44,7 +47,10 @@ const Fund: React.FC<Props> = ({ value, icon, onClick }) => (
onClick={onClick}
>
<DisplayIcon>{icon}</DisplayIcon>
<DisplayTitle>{value.currency}</DisplayTitle>
<MultiRowContainer>
<DisplayTitle>{Currencies[value.currency].displayName}</DisplayTitle>
<DisplaySubTitle>{value.currency}</DisplaySubTitle>
</MultiRowContainer>
<DisplayMoney>
<MainValue>
{fiatToString({
Expand Down

0 comments on commit 32c827d

Please sign in to comment.