Highlight password when unlock fails (#3)

* Highlight password when unlock fails

* Remove old/renamed packages

* manifest.json matched package.json

* Update build script name

* Update package name, skip tests
This commit is contained in:
Jaco Greeff
2019-05-20 14:32:26 +02:00
committed by GitHub
parent 014db3e86c
commit 7f35ea1e8e
6 changed files with 16 additions and 9 deletions
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import { Button, Input } from '../../components';
import { approveRequest } from '../../messaging';
@@ -14,22 +14,32 @@ type Props = {
};
export default function Unlock ({ isVisible, onAction, signId }: Props) {
const [error, setError] = useState('');
const [password, setPassword] = useState('');
if (!isVisible) {
return null;
}
useEffect(() => {
if (error) {
setError('');
}
}, [password]);
const _onSign = (): void => {
approveRequest(signId, password)
.then(onAction)
.catch(console.error);
.catch((error) => {
console.error(error);
setError(error.message);
});
};
return (
<>
<Input
isError={!password}
isError={!password || !!error}
isFocussed
label='password for this account'
onChange={setPassword}