mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-01-12 03:54:13 +00:00
1aad9d1c21
* Convert Swap to consistent style * Generate wallet reducer cleanup. * Confirm empty action in swap reducer * Union types. Fix gen wallet collision * Fix not using all actions in reducer. Added reducer state for is fetching from bity. Added todo to make that a loader. * Readme instructions. * Remove common action constants. * Bring all actions and reducers inline with readme instructions. * Readme fixes * address comments
99 lines
2.6 KiB
JavaScript
99 lines
2.6 KiB
JavaScript
// @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 = (
|
|
<EnterPassword
|
|
walletPasswordForm={this.props.walletPasswordForm}
|
|
generateNewWallet={this.props.generateNewWallet}
|
|
/>
|
|
);
|
|
break;
|
|
|
|
case 'download':
|
|
if (wallet) {
|
|
content = (
|
|
<DownloadWallet
|
|
wallet={wallet}
|
|
password={password}
|
|
continueToPaper={this.props.continueToPaper}
|
|
/>
|
|
);
|
|
}
|
|
break;
|
|
|
|
case 'paper':
|
|
if (wallet) {
|
|
content = <PaperWallet wallet={wallet} />;
|
|
} else {
|
|
content = <h1>Uh oh. Not sure how you got here.</h1>;
|
|
}
|
|
break;
|
|
|
|
default:
|
|
content = <h1>Uh oh. Not sure how you got here.</h1>;
|
|
}
|
|
|
|
return (
|
|
<section className="container" style={{ minHeight: '50%' }}>
|
|
<div className="tab-content">
|
|
<main className="tab-pane active text-center" role="main">
|
|
<section role="main" className="row">
|
|
<br />
|
|
{content}
|
|
</section>
|
|
</main>
|
|
</div>
|
|
</section>
|
|
);
|
|
}
|
|
}
|
|
|
|
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);
|