import React, { useState } from "react"; import { View, TextInput, ActivityIndicator, KeyboardAvoidingView, Platform, } from "react-native"; import { useSirouRouter } from "@sirou/react-native"; import { useLocalSearchParams, Stack } from "expo-router"; import { AppRoutes } from "@/lib/routes"; import { Text } from "@/components/ui/text"; import { Button } from "@/components/ui/button"; import { ScreenWrapper } from "@/components/ScreenWrapper"; import { StandardHeader } from "@/components/StandardHeader"; import { Phone } from "@/lib/icons"; import { api } from "@/lib/api"; import { toast } from "@/lib/toast-store"; import { useColorScheme } from "nativewind"; import { getPlaceholderColor } from "@/lib/colors"; export default function ForgotPinScreen() { const nav = useSirouRouter(); const params = useLocalSearchParams<{ phone?: string }>(); const { colorScheme } = useColorScheme(); const isDark = colorScheme === "dark"; const [phone, setPhone] = useState(params.phone || ""); const [loading, setLoading] = useState(false); const handleSendOtp = async () => { if (!phone || phone.length < 9) { toast.error("Required", "Please enter your phone number"); return; } setLoading(true); const fullPhone = `+251${phone}`; try { const response = await api.auth.forgetPin({ body: { phone: fullPhone } }); toast.success("OTP Sent", response.message || "Verification code sent to your phone"); nav.go("forgot-pin-verify", { phone: fullPhone, verificationId: response.verificationId }); } catch (err: any) { toast.error("Failed", err.message || "Could not send OTP"); } finally { setLoading(false); } }; return ( Forgot your PIN? Enter your phone number to receive a verification code Phone Number +251 ); }