lbry-desktop/src/renderer/component/userEmailVerify/view.jsx

64 lines
1.8 KiB
React
Raw Normal View History

import React from 'react';
import Link from 'component/link';
import { CreditAmount } from 'component/common';
import { Form, FormRow, Submit } from 'component/form.js';
2017-06-03 01:09:52 +02:00
class UserEmailVerify extends React.PureComponent {
2017-06-03 01:09:52 +02:00
constructor(props) {
super(props);
this.state = {
code: '',
2017-06-03 01:09:52 +02:00
};
}
handleCodeChanged(event) {
this.setState({
2017-07-19 01:00:13 +02:00
code: String(event.target.value).trim(),
2017-06-03 01:09:52 +02:00
});
}
handleSubmit() {
const { code } = this.state;
2017-12-23 03:09:06 +01:00
try {
2017-12-26 14:25:26 +01:00
const verification = JSON.parse(atob(code));
2017-12-23 03:09:06 +01:00
this.props.verifyUserEmail(verification.token, verification.recaptcha);
} catch (error) {
2017-12-26 14:25:26 +01:00
this.props.verifyUserEmailFailure('Invalid Verification Token');
2017-12-23 03:09:06 +01:00
}
2017-06-03 01:09:52 +02:00
}
render() {
const { cancelButton, errorMessage, email, isPending, rewardAmount } = this.props;
2017-06-08 23:15:34 +02:00
return (
<Form onSubmit={this.handleSubmit.bind(this)}>
<p>Please enter the verification code emailed to {email}.</p>
2017-06-08 23:15:34 +02:00
<FormRow
type="text"
label={__('Verification Code')}
2017-06-08 23:15:34 +02:00
name="code"
value={this.state.code}
onChange={event => {
this.handleCodeChanged(event);
}}
errorMessage={errorMessage}
/>
{/* render help separately so it always shows */}
<div className="form-field__helper">
<p>
{__('Email')} <Link href="mailto:help@lbry.io" label="help@lbry.io" /> or join our{' '}
<Link href="https://chat.lbry.io" label="chat" />{' '}
{__('if you encounter any trouble with your code.')}
2017-06-08 23:15:34 +02:00
</p>
</div>
<div className="form-row-submit">
<Submit label={__('Verify')} disabled={isPending} />
{cancelButton}
2017-06-08 23:15:34 +02:00
</div>
</Form>
2017-06-08 23:15:34 +02:00
);
2017-06-03 01:09:52 +02:00
}
}
2017-06-08 23:15:34 +02:00
export default UserEmailVerify;