// @flow import * as React from 'react'; import Button from 'component/button'; import { Form, FormField, FormRow, Submit } from 'component/common/form'; type Props = { cancelButton: React.Node, errorMessage: ?string, email: string, isPending: boolean, onModal?: boolean, verifyUserEmail: (string, string) => void, verifyUserEmailFailure: string => void, resendVerificationEmail: string => void, }; type State = { code: string, }; class UserEmailVerify extends React.PureComponent { constructor(props: Props) { super(props); this.state = { code: '', }; (this: any).handleSubmit = this.handleSubmit.bind(this); (this: any).handleResendVerificationEmail = this.handleResendVerificationEmail.bind(this); } handleCodeChanged(event: SyntheticInputEvent<*>) { this.setState({ code: String(event.target.value).trim(), }); } handleSubmit() { const { code } = this.state; try { const verification = JSON.parse(atob(code)); this.props.verifyUserEmail(verification.token, verification.recaptcha); } catch (error) { this.props.verifyUserEmailFailure('Invalid Verification Token'); } } handleResendVerificationEmail() { this.props.resendVerificationEmail(this.props.email); } render() { const { cancelButton, errorMessage, email, isPending, onModal } = this.props; return (

Please enter the verification code emailed to {email}.

this.handleCodeChanged(event)} />
{cancelButton} {!onModal && (

{__('Email')}