// @flow import React, { Component } from 'react'; import { connect } from 'react-redux'; import * as generateWalletActions from 'actions/generateWallet'; import PropTypes from 'prop-types'; 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 = { // FIXME union actual steps activeStep: string, password: string, hasDownloadedWalletFile: boolean, wallet: ?PrivKeyWallet } & typeof generateWalletActions; class GenerateWallet extends Component { props: Props; static propTypes = { // Store state activeStep: PropTypes.string, wallet: PropTypes.object, password: PropTypes.string, hasDownloadedWalletFile: PropTypes.bool, // Actions showPasswordGenerateWallet: PropTypes.func, generateUTCGenerateWallet: PropTypes.func, downloadUTCGenerateWallet: PropTypes.func, confirmContinueToPaperGenerateWallet: PropTypes.func, resetGenerateWallet: PropTypes.func }; 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 { generateWalletPassword: state.form.generateWalletPassword, activeStep: state.generateWallet.activeStep, password: state.generateWallet.password, hasDownloadedWalletFile: state.generateWallet.hasDownloadedWalletFile, wallet: state.generateWallet.wallet, walletFile: state.generateWallet.walletFile }; } export default connect(mapStateToProps, generateWalletActions)(GenerateWallet);