// Copyright 2015-2018 Parity Technologies (UK) Ltd. // This file is part of Parity. // // SPDX-License-Identifier: BSD-3-Clause import React, { Component } from 'react'; import { AccountCard, Form as FetherForm } from 'fether-ui'; import { inject, observer } from 'mobx-react'; @inject('createAccountStore') @observer class AccountPassword extends Component { state = { confirm: '', isLoading: false, password: '', error: '' }; handleConfirmChange = ({ target: { value } }) => { this.setState({ confirm: value }); }; handlePasswordChange = ({ target: { value } }) => { this.setState({ password: value }); }; handleSubmit = event => { const { createAccountStore, history } = this.props; const { confirm, password } = this.state; event.preventDefault(); if (!createAccountStore.jsonString && confirm !== password) { this.setState({ error: 'Password confirmation does not match.' }); return; } this.setState({ isLoading: true }); // Save to parity createAccountStore .saveAccountToParity(password) .then(res => { createAccountStore.clear(); history.push('/accounts'); }) .catch(err => { console.error(err); this.setState({ isLoading: false, error: err.text }); }); }; render () { const { createAccountStore: { address, name, jsonString, isImport }, history, location: { pathname } } = this.props; const { confirm, error, isLoading, password } = this.state; const currentStep = pathname.slice(-1); return (

{' '} {jsonString ? 'Unlock your account to decrypt your JSON keystore file: ' : 'Secure your account with a password:'}

{!jsonString && ( )}

{error && error + ' Please check your password and try again.'}

]} /> ); } } export default AccountPassword;