Skip to content

Commit

Permalink
fix(Swap): get started screen directs to /swap/profile
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-blockchain committed Dec 16, 2018
1 parent 4e213e2 commit edd98a2
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ describe('ExchangeScene', () => {
})
it('renders loading correctly', () => {
const component = shallow(
<ExchangeScene verified={Remote.Loading} {...props} />
<ExchangeScene userCreated={Remote.Loading} {...props} />
)
const tree = toJson(component)
expect(tree).toMatchSnapshot()
})
it('renders not asked correctly', () => {
const component = shallow(
<ExchangeScene verified={Remote.NotAsked} {...props} />
<ExchangeScene userCreated={Remote.NotAsked} {...props} />
)
const tree = toJson(component)
expect(tree).toMatchSnapshot()
})
it('renders exchange correctly', () => {
const component = shallow(
<ExchangeScene verified={Remote.Success(true)} {...props} />
<ExchangeScene userCreated={Remote.Success(true)} {...props} />
)
const tree = toJson(component)
expect(tree).toMatchSnapshot()
Expand All @@ -69,14 +69,14 @@ describe('ExchangeScene', () => {
})
it('renders getstarted correctly', () => {
const component = shallow(
<ExchangeScene verified={Remote.Success(false)} {...props} />
<ExchangeScene userCreated={Remote.Success(false)} {...props} />
)
const tree = toJson(component)
expect(tree).toMatchSnapshot()
})
it('renders failure correctly', () => {
const component = shallow(
<ExchangeScene verified={Remote.Failure({})} {...props} />
<ExchangeScene userCreated={Remote.Failure({})} {...props} />
)
const tree = toJson(component)
expect(tree).toMatchSnapshot()
Expand All @@ -85,7 +85,7 @@ describe('ExchangeScene', () => {
expect(props.fetchUser).toHaveBeenCalledTimes(1)
})
it('logs enter events on mount', () => {
shallow(<ExchangeScene verified={Remote.Failure({})} {...props} />)
shallow(<ExchangeScene userCreated={Remote.Failure({})} {...props} />)
expect(props.logEnterExchange).toHaveBeenCalledTimes(1)
})
})
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
import React from 'react'
import styled from 'styled-components'
import { connect } from 'react-redux'
import { LinkContainer } from 'react-router-bootstrap'
import { FormattedMessage } from 'react-intl'

import { actions } from 'data'
import { Button } from 'blockchain-info-components'

const ActionButton = styled(Button).attrs({ nature: 'primary' })`
font-weight: 500;
`

export const GetStarted = ({ verifyIdentity }) => (
<ActionButton onClick={verifyIdentity}>
<FormattedMessage
id='scenes.exchange.getstarted.status.getstarted.button'
defaultMessage='Get Started'
/>
</ActionButton>
export const GetStarted = () => (
<LinkContainer to='/swap/profile'>
<ActionButton>
<FormattedMessage
id='scenes.exchange.getstarted.status.getstarted.button'
defaultMessage='Get Started'
/>
</ActionButton>
</LinkContainer>
)

const mapDispatchToProps = dispatch => ({
verifyIdentity: () =>
dispatch(actions.components.identityVerification.verifyIdentity())
})

export default connect(
undefined,
mapDispatchToProps
)(GetStarted)
export default GetStarted
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`GetStarted renders correctly 1`] = `
<GetStarted__ActionButton>
<FormattedMessage
defaultMessage="Get Started"
id="scenes.exchange.getstarted.status.getstarted.button"
values={Object {}}
/>
</GetStarted__ActionButton>
<LinkContainer
activeClassName="active"
exact={false}
replace={false}
strict={false}
to="/swap/profile"
>
<GetStarted__ActionButton>
<FormattedMessage
defaultMessage="Get Started"
id="scenes.exchange.getstarted.status.getstarted.button"
values={Object {}}
/>
</GetStarted__ActionButton>
</LinkContainer>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ export class ExchangeScene extends React.PureComponent {
}

render () {
const { verified, hasEmail, location } = this.props
const { userCreated, hasEmail, location } = this.props

if (!hasEmail) return <EmailRequired />

return verified.cata({
Success: verified => (
return userCreated.cata({
Success: userCreated => (
<Wrapper>
{verified ? (
{userCreated ? (
<Container>
<Column>
<Exchange
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { equals } from 'ramda'
import { complement, equals, path } from 'ramda'

import { selectors } from 'data'
import { KYC_STATES } from 'data/modules/profile/model'
import { model, selectors } from 'data'

const { TIERS_STATES } = model.profile

export const getData = state => ({
hasEmail: selectors.core.settings
.getEmail(state)
.map(Boolean)
.getOrElse(false),
verified: selectors.modules.profile
.getUserKYCState(state)
.map(equals(KYC_STATES.VERIFIED))
userCreated: selectors.modules.profile
.getTiers(state)
.map(path([0, 'state']))
.map(complement(equals(TIERS_STATES.NONE)))
})

0 comments on commit edd98a2

Please sign in to comment.