// @flow import type { Node } from 'react'; import React, { useEffect } from 'react'; import Button from 'component/button'; import { FormField } from 'component/common/form'; import UserEmailNew from 'component/userEmailNew'; import UserEmailVerify from 'component/userEmailVerify'; import cookie from 'cookie'; type Props = { cancelButton: Node, email: string, resendVerificationEmail: string => void, checkEmailVerified: () => void, user: { has_verified_email: boolean, }, fetchAccessToken: () => void, accessToken: string, }; function UserEmail(props: Props) { const { email, user, accessToken, fetchAccessToken } = props; const buttonsProps = IS_WEB ? { onClick: () => { document.cookie = cookie.serialize('auth_token', ''); window.location.reload(); }, } : { href: 'https://lbry.com/faq/how-to-change-email' }; let isVerified = false; if (user) { isVerified = user.has_verified_email; } useEffect(() => { if (!accessToken) { fetchAccessToken(); } }, [accessToken, fetchAccessToken]); return (
{!email && } {user && email && !isVerified && } {email && isVerified && (

{__('Email')}

{email && isVerified && __('Your email has been successfully verified')} {!email && __('')}.

{isVerified && ( {__('Your Email')}{' '}
); } export default UserEmail;