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:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user