mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-01-12 12:04:21 +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
79 lines
1.9 KiB
JavaScript
79 lines
1.9 KiB
JavaScript
// @flow
|
|
import React, { Component } from 'react';
|
|
import { Field, reduxForm } from 'redux-form';
|
|
import translate from 'translations';
|
|
import PasswordInput from './PasswordInput';
|
|
|
|
// VALIDATORS
|
|
const minLength = min => value => {
|
|
return value && value.length < min
|
|
? `Must be ${min} characters or more`
|
|
: undefined;
|
|
};
|
|
const minLength9 = minLength(9);
|
|
const required = value => (value ? undefined : 'Required');
|
|
|
|
type Props = {
|
|
walletPasswordForm: Object,
|
|
showWalletPassword: Function,
|
|
generateNewWallet: Function
|
|
};
|
|
|
|
class EnterPassword extends Component {
|
|
props: Props;
|
|
|
|
state = {
|
|
fileName: null,
|
|
blobURI: null,
|
|
isPasswordVisible: false
|
|
};
|
|
|
|
_onClickGenerateFile = () => {
|
|
const form = this.props.walletPasswordForm;
|
|
this.props.generateNewWallet(form.values.password);
|
|
};
|
|
|
|
_togglePassword = () => {
|
|
this.setState({ isPasswordVisible: !this.state.isPasswordVisible });
|
|
};
|
|
|
|
render() {
|
|
const { walletPasswordForm } = this.props;
|
|
const { isPasswordVisible } = this.state;
|
|
|
|
return (
|
|
<div>
|
|
<h1 aria-live="polite">
|
|
{translate('NAV_GenerateWallet')}
|
|
</h1>
|
|
|
|
<div className="col-sm-8 col-sm-offset-2">
|
|
<h4>
|
|
{translate('HELP_1_Desc_3')}
|
|
</h4>
|
|
<Field
|
|
validate={[required, minLength9]}
|
|
component={PasswordInput}
|
|
isPasswordVisible={isPasswordVisible}
|
|
togglePassword={this._togglePassword}
|
|
name="password"
|
|
type="text"
|
|
/>
|
|
<br />
|
|
<button
|
|
onClick={this._onClickGenerateFile}
|
|
disabled={walletPasswordForm ? walletPasswordForm.syncErrors : true}
|
|
className="btn btn-primary btn-block"
|
|
>
|
|
{translate('NAV_GenerateWallet')}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default reduxForm({
|
|
form: 'walletPasswordForm' // a unique name for this form
|
|
})(EnterPassword);
|