lbry-desktop/src/ui/component/syncPassword/view.jsx

58 lines
1.7 KiB
React
Raw Normal View History

// @flow
import React from 'react';
import { Form, FormField } from 'component/common/form';
import Button from 'component/button';
import Card from 'component/common/card';
import { setSavedPassword } from 'util/saved-passwords';
import usePersistedState from 'effects/use-persisted-state';
type Props = {
getSync: (?string) => void,
getSyncIsPending: boolean,
email: string,
};
function SyncPassword(props: Props) {
const { getSync, getSyncIsPending, email } = props;
const [password, setPassword] = React.useState('');
const [rememberPassword, setRememberPassword] = usePersistedState(true);
function handleSubmit() {
setSavedPassword(password, rememberPassword);
getSync(password);
}
return (
<Form onSubmit={handleSubmit}>
<Card
title={__('Enter Your LBRY Password')}
subtitle={__(
'You set your wallet password when you previously installed LBRY. This may have been on different device.'
)}
actions={
<div>
<FormField
type="password"
label={__('Password for %email%', { email })}
value={password}
onChange={e => setPassword(e.target.value)}
/>
<FormField
name="remember-password"
type="checkbox"
label={__('Remember My Password')}
checked={rememberPassword}
onChange={() => setRememberPassword(!rememberPassword)}
/>
<div className="card__actions">
2019-10-04 18:56:09 +02:00
<Button type="submit" button="primary" label={__('Continue')} disabled={getSyncIsPending} />
</div>
</div>
}
/>
</Form>
);
}
export default SyncPassword;