import { Ionicons } from "@expo/vector-icons"; import { useRouter } from "expo-router"; import { useState } from "react"; import { useTranslation } from "react-i18next"; import { ActivityIndicator, KeyboardAvoidingView, Platform, Pressable, Text, TextInput, View, } from "react-native"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { authClient } from "@/src/lib/auth-client"; export default function ForgotPasswordScreen() { const router = useRouter(); const insets = useSafeAreaInsets(); const { t } = useTranslation(); const [email, setEmail] = useState(""); const [isPending, setIsPending] = useState(false); const [sent, setSent] = useState(false); const [error, setError] = useState(null); async function handleSend() { if (!email.trim()) return; setIsPending(true); setError(null); const result = await authClient.requestPasswordReset({ email: email.trim(), redirectTo: "haushaltsApp://reset-password", }); setIsPending(false); if (result.error) { setError(result.error.message ?? t('common.error')); } else { setSent(true); } } return ( router.back()} className="p-1 mr-2 active:opacity-50"> {t('forgotPassword.title')} {t('forgotPassword.subtitle')} {sent ? ( {t('forgotPassword.sentTitle')} {t('forgotPassword.sentHint')} ) : ( <> {t('login.emailLabel')} {error && ( {error} )} {isPending ? ( ) : ( {t('forgotPassword.sendButton')} )} )} ); }