import * as React from 'react'; import I18n from 'i18n-js'; import Box from '../common/Box'; import Button from '../common/Button'; import { TenantSignUpUserFormState } from '../../reducers/tenantSignUpReducer'; interface Props { currentStep: number; emailAuth: boolean; toggleEmailAuth(): void; userForm: TenantSignUpUserFormState; handleChangeUserFullName(fullName: string): void; handleChangeUserEmail(email: string): void; handleChangeUserPassword(password: string): void; handleChangeUserPasswordConfirmation(passwordConfirmation: string): void; handleUserFormConfirm(): void; } class UserSignUpForm extends React.Component { form: any; constructor(props: Props) { super(props); this.form = React.createRef(); } validateUserForm(): boolean { let isValid: boolean = this.form.current.reportValidity(); if (this.validateUserPasswordConfirmation() === false) isValid = false; return isValid; } validateUserPasswordConfirmation(): boolean { const isValid = this.props.userForm.password === this.props.userForm.passwordConfirmation; return isValid; } render() { const { currentStep, emailAuth, toggleEmailAuth, userForm, handleChangeUserFullName, handleChangeUserEmail, handleChangeUserPassword, handleChangeUserPasswordConfirmation, handleUserFormConfirm, } = this.props; return (

{ I18n.t('signup.step1.title') }

{ currentStep === 1 && !emailAuth && } { currentStep === 1 && emailAuth &&
handleChangeUserFullName(e.target.value)} placeholder={I18n.t('common.forms.auth.full_name')} required id="userFullName" className="formControl" />
handleChangeUserEmail(e.target.value)} placeholder={I18n.t('common.forms.auth.email')} required id="userEmail" className="formControl" />
handleChangeUserPassword(e.target.value)} placeholder={I18n.t('common.forms.auth.password')} required minLength={6} maxLength={128} id="userPassword" className="formControl" />
handleChangeUserPasswordConfirmation(e.target.value)} placeholder={I18n.t('common.forms.auth.password_confirmation')} required minLength={6} maxLength={128} id="userPasswordConfirmation" className={`formControl${userForm.passwordConfirmationError ? ' invalid' : ''}`} />
} { currentStep === 2 &&

{userForm.fullName} ({userForm.email})

}
); } } export default UserSignUpForm;