|
@ -1,7 +1,12 @@ |
|
|
// @flow
|
|
|
// @flow
|
|
|
|
|
|
|
|
|
import React, { Fragment, PureComponent } from 'react' |
|
|
import React, { Fragment, PureComponent } from 'react' |
|
|
|
|
|
import { compose } from 'redux' |
|
|
|
|
|
import { connect } from 'react-redux' |
|
|
import { translate } from 'react-i18next' |
|
|
import { translate } from 'react-i18next' |
|
|
|
|
|
import { createStructuredSelector } from 'reselect' |
|
|
|
|
|
|
|
|
|
|
|
import { accountsSelector } from 'reducers/accounts' |
|
|
|
|
|
|
|
|
import type { Account } from '@ledgerhq/live-common/lib/types' |
|
|
import type { Account } from '@ledgerhq/live-common/lib/types' |
|
|
import type { T, Device } from 'types/common' |
|
|
import type { T, Device } from 'types/common' |
|
@ -26,6 +31,7 @@ import StepReceiveFunds from './04-step-receive-funds' |
|
|
|
|
|
|
|
|
type Props = { |
|
|
type Props = { |
|
|
t: T, |
|
|
t: T, |
|
|
|
|
|
accounts: Account[], |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
type State = { |
|
|
type State = { |
|
@ -57,6 +63,10 @@ const INITIAL_STATE = { |
|
|
stepsErrors: [], |
|
|
stepsErrors: [], |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = createStructuredSelector({ |
|
|
|
|
|
accounts: accountsSelector, |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
class ReceiveModal extends PureComponent<Props, State> { |
|
|
class ReceiveModal extends PureComponent<Props, State> { |
|
|
state = INITIAL_STATE |
|
|
state = INITIAL_STATE |
|
|
|
|
|
|
|
@ -178,11 +188,19 @@ class ReceiveModal extends PureComponent<Props, State> { |
|
|
|
|
|
|
|
|
handleBeforeOpenModal = ({ data }) => { |
|
|
handleBeforeOpenModal = ({ data }) => { |
|
|
const { account } = this.state |
|
|
const { account } = this.state |
|
|
if (data && data.account && !account) { |
|
|
const { accounts } = this.props |
|
|
|
|
|
|
|
|
|
|
|
if (!account) { |
|
|
|
|
|
if (data && data.account) { |
|
|
this.setState({ |
|
|
this.setState({ |
|
|
account: data.account, |
|
|
account: data.account, |
|
|
stepIndex: 1, |
|
|
stepIndex: 1, |
|
|
}) |
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
this.setState({ |
|
|
|
|
|
account: accounts[0], |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -348,4 +366,7 @@ class ReceiveModal extends PureComponent<Props, State> { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export default translate()(ReceiveModal) |
|
|
export default compose( |
|
|
|
|
|
connect(mapStateToProps), |
|
|
|
|
|
translate(), |
|
|
|
|
|
)(ReceiveModal) |
|
|