// @flow import React, { Component } from 'react'; import { connect } from 'react-redux'; import * as generateWalletActions from 'actions/generateWallet'; import type { GenerateNewWalletAction, ContinueToPaperAction, ResetGenerateWalletAction } from 'actions/generateWallet'; import EnterPassword from './components/EnterPassword'; import DownloadWallet from './components/DownloadWallet'; import PaperWallet from './components/PaperWallet'; import type PrivKeyWallet from 'libs/wallet/privkey'; import type { State } from 'reducers'; type Props = { // Redux state activeStep: string, // FIXME union actual steps password: string, wallet: ?PrivKeyWallet, walletPasswordForm: Object, // Actions generateNewWallet: (pw: string) => GenerateNewWalletAction, continueToPaper: () => ContinueToPaperAction, resetGenerateWallet: () => ResetGenerateWalletAction }; class GenerateWallet extends Component { props: Props; componentWillUnmount() { this.props.resetGenerateWallet(); } render() { const { activeStep, wallet, password } = this.props; let content; switch (activeStep) { case 'password': content = ( ); break; case 'download': if (wallet) { content = ( ); } break; case 'paper': if (wallet) { content = ; } else { content =

Uh oh. Not sure how you got here.

; } break; default: content =

Uh oh. Not sure how you got here.

; } return (

{content}
); } } function mapStateToProps(state: State) { return { walletPasswordForm: state.form.walletPasswordForm, activeStep: state.generateWallet.activeStep, password: state.generateWallet.password, wallet: state.generateWallet.wallet }; } export default connect(mapStateToProps, generateWalletActions)(GenerateWallet);