import { useIntl } from 'react-intl' import { Alert, Box, Button, Input, Label } from 'theme-ui' import React, { useRef } from 'react' import type { FC } from 'react' import type { State } from './state' interface Props { variant: string onSubmit: ( email: string, password: string, confirmPassword: string ) => Promise onBack: () => void state: State } const SignUpForm: FC = ({ variant, onSubmit, onBack, state: { state, email }, }) => { const { formatMessage } = useIntl() const code = useRef(null) const password = useRef(null) const confirmPwd = useRef(null) return ( <> {formatMessage({ id: 'login.page.emailAndPassword.signUpForm.title', })} {formatMessage( { id: 'login.page.emailAndPassword.signUpForm.subTitle', }, { email, } )} { e.preventDefault() onSubmit( code.current?.value ?? '', password.current?.value ?? '', confirmPwd.current?.value ?? '' ) }} variant={variant} > {state === 'signUpForm.invalidAccessCodeInput' && ( {formatMessage({ id: 'login.page.emailAndPassword.signUpForm.invalidAccessCodeInput', })} )} {state === 'signUpForm.invalidPassword' && ( {formatMessage({ id: 'login.page.emailAndPassword.signUpForm.invalidPassword', })} )} {state === 'signUpForm.passwordDoNotMatch' && ( {formatMessage({ id: 'login.page.emailAndPassword.signUpForm.passwordDoNotMatch', })} )} {state === 'signUpForm.error' && ( {formatMessage({ id: 'login.page.emailAndPassword.signUpForm.error', })} )} ) } export default SignUpForm