From ffe71f502d3388121d1cfdacfa18cbea4895f5da Mon Sep 17 00:00:00 2001 From: Anita Date: Sat, 18 Apr 2026 19:15:56 +0100 Subject: feat(auth): mejora UX login y register (mostrar contraseña y validación) refs #6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(auth)/register.tsx | 85 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 75 insertions(+), 10 deletions(-) (limited to 'src/app/(auth)/register.tsx') diff --git a/src/app/(auth)/register.tsx b/src/app/(auth)/register.tsx index 0b57ce5..902c752 100644 --- a/src/app/(auth)/register.tsx +++ b/src/app/(auth)/register.tsx @@ -1,6 +1,7 @@ import { Link } from 'expo-router'; import { Pressable, StyleSheet, Text, TextInput, View } from 'react-native'; import { MaterialIcons } from '@expo/vector-icons'; +import { useState } from 'react'; import theme from '@/theme'; import { useRegister } from '@/features/auth/hooks/useRegister'; import { StatusMessage } from '@/shared/ui/StatusMessage'; @@ -21,6 +22,27 @@ export default function RegisterScreen() { error, } = useRegister(); + // estado para confirmar contraseña + const [confirmPassword, setConfirmPassword] = useState(''); + + // estados para mostrar/ocultar contraseña + const [showPassword, setShowPassword] = useState(false); + const [showConfirmPassword, setShowConfirmPassword] = useState(false); + + // error local (frontend) + const [localError, setLocalError] = useState(null); + + const handleSubmit = () => { + setLocalError(null); + + if (password !== confirmPassword) { + setLocalError('Las contraseñas no coinciden'); + return; + } + + submit(); + }; + return ( {/* contenido central acotado */} @@ -62,20 +84,62 @@ export default function RegisterScreen() { {/* campo contraseña */} Contraseña - + + + + setShowPassword((prev) => !prev)} + style={styles.iconButton} + > + + + + + {/* campo confirmar contraseña */} + Confirmar contraseña + + + + setShowConfirmPassword((prev) => !prev)} + style={styles.iconButton} + > + + + {/* mensaje de error */} + {localError ? : null} {error ? : null} {/* boton principal */} - + {isSubmitting ? 'Registrando...' : 'Crear cuenta'} @@ -84,7 +148,8 @@ export default function RegisterScreen() { {/* enlace inferior a login */} - ¿Ya tienes cuenta? Inicia sesión + ¿Ya tienes cuenta?{' '} + Inicia sesión -- cgit v1.2.3-54-g00ecf