2018-04-03 17:14:55 +02:00
|
|
|
// @flow
|
2018-06-07 03:47:49 +02:00
|
|
|
import * as React from 'react';
|
2018-03-26 23:32:43 +02:00
|
|
|
import Button from 'component/button';
|
2019-07-19 16:52:42 +02:00
|
|
|
import UserEmailResetButton from 'component/userEmailResetButton';
|
2017-06-03 01:09:52 +02:00
|
|
|
|
2018-04-03 17:14:55 +02:00
|
|
|
type Props = {
|
|
|
|
email: string,
|
2018-06-07 03:47:49 +02:00
|
|
|
resendVerificationEmail: string => void,
|
2019-01-09 06:01:45 +01:00
|
|
|
checkEmailVerified: () => void,
|
2019-01-08 03:46:33 +01:00
|
|
|
user: {
|
|
|
|
has_verified_email: boolean,
|
|
|
|
},
|
2018-04-03 17:14:55 +02:00
|
|
|
};
|
|
|
|
|
2019-01-08 03:46:33 +01:00
|
|
|
class UserEmailVerify extends React.PureComponent<Props> {
|
2018-04-03 17:14:55 +02:00
|
|
|
constructor(props: Props) {
|
2017-06-03 01:09:52 +02:00
|
|
|
super(props);
|
2019-01-08 03:46:33 +01:00
|
|
|
this.emailVerifyCheckInterval = null;
|
2018-06-07 04:40:32 +02:00
|
|
|
(this: any).handleResendVerificationEmail = this.handleResendVerificationEmail.bind(this);
|
2017-06-03 01:09:52 +02:00
|
|
|
}
|
|
|
|
|
2019-01-08 03:46:33 +01:00
|
|
|
componentDidMount() {
|
|
|
|
this.emailVerifyCheckInterval = setInterval(() => this.checkIfVerified(), 5000);
|
2017-06-03 01:09:52 +02:00
|
|
|
}
|
|
|
|
|
2019-01-08 03:46:33 +01:00
|
|
|
componentDidUpdate() {
|
|
|
|
if (this.emailVerifyCheckInterval && this.props.user.has_verified_email) {
|
|
|
|
clearInterval(this.emailVerifyCheckInterval);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
if (this.emailVerifyCheckInterval) {
|
|
|
|
clearInterval(this.emailVerifyCheckInterval);
|
2017-12-23 03:09:06 +01:00
|
|
|
}
|
2017-06-03 01:09:52 +02:00
|
|
|
}
|
|
|
|
|
2018-06-07 04:40:32 +02:00
|
|
|
handleResendVerificationEmail() {
|
2018-06-07 03:47:49 +02:00
|
|
|
this.props.resendVerificationEmail(this.props.email);
|
|
|
|
}
|
|
|
|
|
2019-01-08 03:46:33 +01:00
|
|
|
checkIfVerified() {
|
2019-01-09 06:01:45 +01:00
|
|
|
const { checkEmailVerified } = this.props;
|
|
|
|
checkEmailVerified();
|
2019-01-08 03:46:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
emailVerifyCheckInterval: ?IntervalID;
|
|
|
|
|
2017-06-03 01:09:52 +02:00
|
|
|
render() {
|
2019-07-18 00:48:11 +02:00
|
|
|
const { email } = this.props;
|
|
|
|
|
2017-06-08 23:15:34 +02:00
|
|
|
return (
|
2019-01-22 19:29:45 +01:00
|
|
|
<React.Fragment>
|
|
|
|
<header className="card__header">
|
|
|
|
<h2 className="card__title">{__('Waiting For Verification')}</h2>
|
|
|
|
</header>
|
2018-12-19 06:44:53 +01:00
|
|
|
|
2019-01-22 19:29:45 +01:00
|
|
|
<div className="card__content">
|
2019-06-17 22:32:38 +02:00
|
|
|
<p className="card__subtitle">
|
2019-01-22 19:29:45 +01:00
|
|
|
{__('An email was sent to')} {email}.{' '}
|
|
|
|
{__('Follow the link and you will be good to go. This will update automatically.')}
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<div className="card__actions">
|
|
|
|
<Button
|
|
|
|
button="primary"
|
|
|
|
label={__('Resend verification email')}
|
|
|
|
onClick={this.handleResendVerificationEmail}
|
|
|
|
/>
|
2019-07-18 00:48:11 +02:00
|
|
|
|
2019-07-19 16:52:42 +02:00
|
|
|
<UserEmailResetButton />
|
2019-01-22 19:29:45 +01:00
|
|
|
</div>
|
2018-12-19 06:44:53 +01:00
|
|
|
|
2019-01-22 19:29:45 +01:00
|
|
|
<p className="help">
|
2019-05-07 23:38:29 +02:00
|
|
|
{__('Email')} <Button button="link" href="mailto:help@lbry.com" label="help@lbry.com" /> or join our{' '}
|
|
|
|
<Button button="link" href="https://chat.lbry.com" label="chat" />{' '}
|
2019-01-22 19:29:45 +01:00
|
|
|
{__('if you encounter any trouble verifying.')}
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</React.Fragment>
|
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;
|