import React, { useState } from 'react'; import { StyleSheet, View } from 'react-native'; import { Link } from 'expo-router'; import { useThemeColor } from '@/hooks/use-theme-color'; import { Button, Input } from '@/components/ui'; import { Text } from '@/components/ui/Text'; import { AuthScreen } from '@/components/auth/AuthScreen'; import { useAuth } from '@/context/AuthContext'; import { useToast } from '@/context/ToastContext'; import { translateError } from '@/lib/errors/translations'; export default function ForgotPasswordScreen() { const [email, setEmail] = useState(''); const [emailSent, setEmailSent] = useState(false); const [errors, setErrors] = useState<{ email?: string }>({}); const { forgotPassword } = useAuth(); const { showToast } = useToast(); const [loading, setLoading] = useState(false); const textColor = useThemeColor({}, 'text'); const tintColor = useThemeColor({}, 'tint'); const validateForm = () => { const newErrors: { email?: string } = {}; if (!email) { newErrors.email = 'Email é obrigatório'; } else if (!/\S+@\S+\.\S+/.test(email)) { newErrors.email = 'Por favor entre um email válido'; } setErrors(newErrors); return Object.keys(newErrors).length === 0; }; const handleForgotPassword = async () => { if (!validateForm()) return; setLoading(true); try { await forgotPassword(email); setEmailSent(true); } catch (error) { showToast(translateError(error) || 'Falha ao enviar link de recuperação', 'error'); } finally { setLoading(false); } }; if (emailSent) { return (