// @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,
};
function UserEmailNew(props: Props) {
const { errorMessage, isPending, addUserEmail, setSync } = props;
const [newEmail, setEmail] = useState('');
const [formSyncEnabled, setFormSyncEnabled] = useState(true);
const valid = newEmail.match(EMAIL_REGEX);
function handleSubmit() {
setSync(formSyncEnabled);
addUserEmail(newEmail);
analytics.emailProvidedEvent();
}
return (
{/* @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 */}
{__('Sign In to lbry.tv')}