import { useIntl } from 'react-intl' import { Alert, Box, Button, Input } from 'theme-ui' import React, { useRef } from 'react' import type { FC } from 'react' import type { State } from './state' interface Props { variant: string state: State onBack: () => void onSubmit: (email: string) => Promise } const EmailForm: FC = ({ variant, state: { state }, onSubmit, onBack, }) => { const { formatMessage } = useIntl() const input = useRef(null) return ( <> {formatMessage({ id: 'login.page.emailAndPassword.emailForm.title', })} { e.preventDefault() onSubmit(input.current?.value ?? '') }} variant={variant} > {state === 'emailForm.invalidEmailInput' && ( {formatMessage({ id: 'login.page.emailAndPassword.emailForm.invalidEmailInput', })} )} {state === 'emailForm.error' && ( {formatMessage({ id: 'login.page.emailAndPassword.emailForm.error', })} )} ) } export default EmailForm