2017-04-18 23:01:25 +00:00
|
|
|
import React, {Component} from "react";
|
|
|
|
import PropTypes from "prop-types";
|
2017-04-14 01:27:28 +00:00
|
|
|
|
2017-04-25 00:00:58 +00:00
|
|
|
import {Field, reduxForm} from "redux-form";
|
2017-04-18 23:01:25 +00:00
|
|
|
import GenerateWalletPasswordInputComponent from "./GenerateWalletPasswordInputComponent";
|
|
|
|
|
|
|
|
|
2017-04-25 00:00:58 +00:00
|
|
|
// VALIDATORS
|
|
|
|
const minLength = min => value => {
|
|
|
|
return value && value.length < min ? `Must be ${min} characters or more` : undefined
|
|
|
|
}
|
|
|
|
const minLength9 = minLength(9)
|
2017-04-18 23:01:25 +00:00
|
|
|
const required = value => value ? undefined : 'Required'
|
|
|
|
|
|
|
|
|
|
|
|
class GenerateWalletPasswordComponent extends Component {
|
2017-04-14 01:27:28 +00:00
|
|
|
constructor(props) {
|
|
|
|
super(props)
|
|
|
|
}
|
|
|
|
|
|
|
|
static propTypes = {
|
2017-04-14 06:26:25 +00:00
|
|
|
title: PropTypes.string,
|
|
|
|
body: PropTypes.string,
|
|
|
|
userId: PropTypes.number,
|
2017-04-18 23:01:25 +00:00
|
|
|
id: PropTypes.number,
|
|
|
|
generateWalletPassword: PropTypes.object,
|
|
|
|
showPassword: PropTypes.bool,
|
|
|
|
showGenerateWalletPasswordAction: PropTypes.func,
|
|
|
|
generateWalletFileAction: PropTypes.func,
|
|
|
|
generateWalletFile: PropTypes.bool
|
2017-04-14 01:27:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
2017-04-18 23:01:25 +00:00
|
|
|
const {
|
|
|
|
// handleSubmit,
|
|
|
|
// pristine,
|
|
|
|
// reset,
|
|
|
|
// submitting,
|
|
|
|
generateWalletPassword,
|
|
|
|
showPassword,
|
|
|
|
showGenerateWalletPasswordAction,
|
|
|
|
generateWalletFileAction,
|
|
|
|
generateWalletFile
|
|
|
|
|
|
|
|
} = this.props;
|
|
|
|
|
2017-04-14 01:27:28 +00:00
|
|
|
return (
|
|
|
|
<section className="container" style={{minHeight: '50%'}}>
|
|
|
|
<div className="tab-content">
|
|
|
|
<main className="tab-pane active text-center" role="main">
|
|
|
|
<section className="row">
|
|
|
|
<h1 aria-live="polite">Generate Wallet</h1>
|
|
|
|
<div className="col-sm-8 col-sm-offset-2">
|
|
|
|
<h4>Enter a strong password (at least 9 characters)</h4>
|
2017-04-18 23:01:25 +00:00
|
|
|
<Field
|
|
|
|
validate={[required, minLength9]}
|
|
|
|
component={GenerateWalletPasswordInputComponent}
|
|
|
|
showPassword={showPassword}
|
|
|
|
showGenerateWalletPasswordAction={showGenerateWalletPasswordAction}
|
|
|
|
name="password"
|
|
|
|
type="text"/>
|
2017-04-14 01:27:28 +00:00
|
|
|
<br/>
|
2017-04-18 23:01:25 +00:00
|
|
|
<button onClick={() => generateWalletFileAction()}
|
|
|
|
disabled={generateWalletPassword ? generateWalletPassword.syncErrors : true}
|
|
|
|
className="btn btn-primary btn-block">
|
2017-04-14 01:27:28 +00:00
|
|
|
Generate Wallet
|
2017-04-18 23:01:25 +00:00
|
|
|
</button>
|
|
|
|
{
|
|
|
|
generateWalletFile && (
|
|
|
|
<div>
|
|
|
|
<br/>
|
2017-04-25 00:00:58 +00:00
|
|
|
<p style={{color: 'red'}}> Now you need to confirm that you copied your
|
|
|
|
seed!</p>
|
2017-04-18 23:01:25 +00:00
|
|
|
</div>)
|
|
|
|
|
2017-04-25 00:00:58 +00:00
|
|
|
}
|
2017-04-14 01:27:28 +00:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</main>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2017-04-18 23:01:25 +00:00
|
|
|
|
|
|
|
export default reduxForm({
|
|
|
|
form: 'generateWalletPassword' // a unique name for this form
|
|
|
|
})(GenerateWalletPasswordComponent);
|