// @flow import React, { useState } from 'react'; import { FormField, Form } from 'component/common/form'; import Button from 'component/button'; import analytics from 'analytics'; import { EMAIL_REGEX } from 'constants/email'; import I18nMessage from 'component/i18nMessage'; type Props = { errorMessage: ?string, isPending: boolean, addUserEmail: string => void, syncEnabled: boolean, setSync: boolean => void, balance: number, daemonSettings: { share_usage_data: boolean }, setShareDiagnosticData: boolean => void, }; function UserEmailNew(props: Props) { const { errorMessage, isPending, addUserEmail, setSync, daemonSettings, setShareDiagnosticData } = props; const { share_usage_data: shareUsageData } = daemonSettings; const [newEmail, setEmail] = useState(''); const [localShareUsageData, setLocalShareUsageData] = React.useState(false); const [formSyncEnabled, setFormSyncEnabled] = useState(true); const valid = newEmail.match(EMAIL_REGEX); function handleUsageDataChange() { setLocalShareUsageData(!localShareUsageData); } function handleSubmit() { setSync(formSyncEnabled); addUserEmail(newEmail); // @if TARGET='app' setShareDiagnosticData(true); // @endif analytics.emailProvidedEvent(); } return ( {__('Sign In to lbry.tv')} {/* @if TARGET='web' */} {__('Create a new account or sign in.')} {/* @endif */} {/* @if TARGET='app' */} {__('An account with lbry.tv allows you to earn rewards and backup your data.')} {/* @endif */} setEmail(e.target.value)} /> {!IS_WEB && ( {__('Backup your account and wallet data.')}{' '} } checked={formSyncEnabled} onChange={() => setFormSyncEnabled(!formSyncEnabled)} /> )} {!shareUsageData && !IS_WEB && ( {__('Share usage data with LBRY inc.')}{' '} {!localShareUsageData && ({__('Required')})} } /> )} {/* @if TARGET='web' */} ), }} > By continuing, I agree to the %terms% and confirm I am over the age of 13. {/* @endif */} ); } export default UserEmailNew;
{/* @if TARGET='web' */} {__('Create a new account or sign in.')} {/* @endif */} {/* @if TARGET='app' */} {__('An account with lbry.tv allows you to earn rewards and backup your data.')} {/* @endif */}
), }} > By continuing, I agree to the %terms% and confirm I am over the age of 13.