import { ChangeEvent } from 'react'; import React, { FC, useState, memo } from '../../lib/teact/teact'; import { getActions, withGlobal } from '../../modules'; import { GlobalState } from '../../global/types'; import { pick } from '../../util/iteratees'; import useLang from '../../hooks/useLang'; import Button from '../ui/Button'; import InputText from '../ui/InputText'; import AvatarEditable from '../ui/AvatarEditable'; type StateProps = Pick; const AuthRegister: FC = ({ authIsLoading, authError, }) => { const { signUp, clearAuthError, uploadProfilePhoto } = getActions(); const lang = useLang(); const [isButtonShown, setIsButtonShown] = useState(false); const [croppedFile, setCroppedFile] = useState(); const [firstName, setFirstName] = useState(''); const [lastName, setLastName] = useState(''); function handleFirstNameChange(event: ChangeEvent) { if (authError) { clearAuthError(); } const { target } = event; setFirstName(target.value); setIsButtonShown(target.value.length > 0); } function handleLastNameChange(event: ChangeEvent) { const { target } = event; setLastName(target.value); } function handleSubmit(event: React.FormEvent) { event.preventDefault(); signUp({ firstName, lastName }); if (croppedFile) { uploadProfilePhoto({ file: croppedFile }); } } return (

{lang('YourName')}

{lang('Login.Register.Desc')}

{isButtonShown && ( )}
); }; export default memo(withGlobal( (global): StateProps => pick(global, ['authIsLoading', 'authError']), )(AuthRegister));