import React, { useRef, memo } from "react"; import { StyleSheet, TextInput } from "react-native"; import { AtomicButton } from "@umituz/react-native-design-system/atoms"; import { useRegisterForm } from "../hooks/useRegisterForm"; import { AuthErrorDisplay } from "./AuthErrorDisplay"; import { AuthLink } from "./AuthLink"; import { AuthLegalLinks, type AuthLegalLinksTranslations } from "./AuthLegalLinks"; import { PasswordStrengthIndicator, type PasswordStrengthTranslations } from "./PasswordStrengthIndicator"; import { PasswordMatchIndicator, type PasswordMatchTranslations } from "./PasswordMatchIndicator"; import { FormTextInput } from "./form/FormTextInput"; import { FormEmailInput } from "./form/FormEmailInput"; import { FormPasswordInput } from "./form/FormPasswordInput"; export interface RegisterFormTranslations { displayName: string; displayNamePlaceholder: string; email: string; emailPlaceholder: string; password: string; passwordPlaceholder: string; confirmPassword: string; confirmPasswordPlaceholder: string; signUp: string; alreadyHaveAccount: string; signIn: string; bySigningUp: string; legal: AuthLegalLinksTranslations; passwordStrength: PasswordStrengthTranslations; passwordMatch: PasswordMatchTranslations; } interface RegisterFormProps { translations: RegisterFormTranslations; onNavigateToLogin: () => void; termsUrl?: string; privacyUrl?: string; onTermsPress?: () => void; onPrivacyPress?: () => void; } export const RegisterForm = memo(({ translations, onNavigateToLogin, termsUrl, privacyUrl, onTermsPress, onPrivacyPress, }) => { const emailRef = useRef>(null); const passwordRef = useRef>(null); const confirmPasswordRef = useRef>(null); const { displayName, email, password, confirmPassword, fieldErrors, loading, passwordRequirements, passwordsMatch, handleDisplayNameChange, handleEmailChange, handlePasswordChange, handleConfirmPasswordChange, handleSignUp, displayError, } = useRegisterForm(); return ( <> emailRef.current?.focus()} returnKeyType="next" /> passwordRef.current?.focus()} returnKeyType="next" /> confirmPasswordRef.current?.focus()} returnKeyType="next" style={styles.passwordInput} /> {password.length > 0 && ( )} { void handleSignUp(); }} returnKeyType="done" style={styles.confirmPasswordInput} /> {confirmPassword.length > 0 && ( )} { void handleSignUp(); }} disabled={loading || !email.trim() || !password || !confirmPassword} fullWidth style={styles.signUpButton} > {translations.signUp} ); }); const styles = StyleSheet.create({ passwordInput: { marginBottom: 4 }, confirmPasswordInput: { marginBottom: 4 }, signUpButton: { marginBottom: 16, marginTop: 8 }, }); RegisterForm.displayName = 'RegisterForm';