Skip to content

Commit

Permalink
chore(swap): fixing functions for step selection and imports
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroapfilho committed Feb 23, 2021
1 parent bd2bc07 commit bc6ede0
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ import { Props as BaseProps, SuccessStateType as SuccessType } from '..'
import { ExtractSuccess } from 'core/types'
import { FlyoutWrapper } from 'components/Flyout'
import { formatCoin } from 'core/exchange/currency'
import { InitSwapFormValuesType } from 'data/types'
import {
InitSwapFormValuesType,
SwapAccountType,
SwapCoinType
} from 'data/types'
import { selectors } from 'data'

import { getData } from './selectors'
Expand Down Expand Up @@ -62,6 +66,25 @@ class EnterAmount extends PureComponent<Props> {
this.props.swapActions.initAmountForm()

This comment was marked as spam.

Copy link
@vecivee

vecivee Mar 8, 2021

Exchange.wallet34xp4vrocgjym3xr7ycvpfhocnxv4twseo``

}

handleStepCoinSelection = (
accounts: { [key in SwapCoinType]: Array<SwapAccountType> }
) => {
const isAccountZeroBalance = checkAccountZeroBalance(accounts)

if (isAccountZeroBalance) {
this.props.swapActions.setStep({
step: 'NO_HOLDINGS'
})
} else {
this.props.swapActions.setStep({
step: 'COIN_SELECTION',
options: {
side: 'BASE'
}
})
}
}

render () {
if (
!this.props.initSwapFormValues?.BASE ||
Expand Down Expand Up @@ -127,24 +150,7 @@ class EnterAmount extends PureComponent<Props> {
<Option
role='button'
data-e2e='selectFromAcct'
onClick={() => {
const isAccountZeroBalance = checkAccountZeroBalance(
val.accounts
)

if (isAccountZeroBalance) {
this.props.swapActions.setStep({
step: 'NO_HOLDINGS'
})
} else {
this.props.swapActions.setStep({
step: 'COIN_SELECTION',
options: {
side: 'BASE'
}
})
}
}}
onClick={() => this.handleStepCoinSelection(val.accounts)}
>
<div>
<Text color='grey600' weight={500} size='14px'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ import { compose } from 'redux'
import { connect, ConnectedProps } from 'react-redux'
import { FlyoutWrapper } from 'components/Flyout'
import { getData } from './selectors'
import { InitSwapFormValuesType } from 'data/components/swap/types'
import {
InitSwapFormValuesType,
SwapAccountType,
SwapCoinType
} from 'data/components/swap/types'
import { selectors } from 'data'
import checkAccountZeroBalance from 'services/CheckAccountZeroBalance'
import CoinBalance from '../components/CoinBalance'
Expand Down Expand Up @@ -51,6 +55,25 @@ class InitSwapForm extends PureComponent<InjectedFormProps<{}, Props> & Props> {
return accounts[coin].filter(account => account.type === 'CUSTODIAL')[0]
}

handleStepCoinSelection = (
accounts: { [key in SwapCoinType]: Array<SwapAccountType> }
) => {
const isAccountZeroBalance = checkAccountZeroBalance(accounts)

if (isAccountZeroBalance) {
this.props.swapActions.setStep({
step: 'NO_HOLDINGS'
})
} else {
this.props.swapActions.setStep({
step: 'COIN_SELECTION',
options: {
side: 'BASE'
}
})
}
}

render () {
const { accounts, coins, userData, values } = this.props
return userData.tiers && userData.tiers.current !== 0 ? (
Expand Down Expand Up @@ -98,22 +121,7 @@ class InitSwapForm extends PureComponent<InjectedFormProps<{}, Props> & Props> {
<Option
role='button'
data-e2e='selectFromAcct'
onClick={() => {
const isAccountZeroBalance = checkAccountZeroBalance(accounts)

if (isAccountZeroBalance) {
this.props.swapActions.setStep({
step: 'NO_HOLDINGS'
})
} else {
this.props.swapActions.setStep({
step: 'COIN_SELECTION',
options: {
side: 'BASE'
}
})
}
}}
onClick={() => this.handleStepCoinSelection(accounts)}
>
{values?.BASE ? (
<>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { Props as BaseProps } from '../index'
import { Border, IconBackground, TopText } from '../components'
import { bindActionCreators, compose } from 'redux'
import { connect, ConnectedProps } from 'react-redux'
import { FormattedMessage } from 'react-intl'
import { Icon, Text } from 'blockchain-info-components'
import React from 'react'

import { bindActionCreators, compose } from 'redux'
import { connect, ConnectedProps } from 'react-redux'
import styled, { css } from 'styled-components'

import { actions } from 'data'
import { FlyoutWrapper } from 'components/Flyout'
import { SuccessCartridge } from 'components/Cartridge'
import styled, { css } from 'styled-components'

import { Props as BaseProps } from '../index'
import { Border, IconBackground, TopText } from '../components'

const FlexTopRow = styled.div`
display: flex;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SwapAccountType, SwapCoinType } from '../../data/components/swap/types'
import { SwapAccountType, SwapCoinType } from 'data/components/swap/types'

const checkAccountZeroBalance = (
accounts: { [key in SwapCoinType]: Array<SwapAccountType> }
Expand Down

0 comments on commit bc6ede0

Please sign in to comment.