import React, { useState } from "react"; import { View, ScrollView, Pressable, TextInput, ActivityIndicator, useColorScheme, } from "react-native"; import { useSirouRouter } from "@sirou/react-native"; import { AppRoutes } from "@/lib/routes"; import { Text } from "@/components/ui/text"; import { Button } from "@/components/ui/button"; import { ScreenWrapper } from "@/components/ScreenWrapper"; import { ArrowLeft, Lock, Eye, EyeOff } from "@/lib/icons"; import { api } from "@/lib/api"; import { toast } from "@/lib/toast-store"; export default function ChangePinScreen() { const nav = useSirouRouter(); const isDark = useColorScheme() === "dark"; const iconColor = isDark ? "#94a3b8" : "#64748b"; const [currentPassword, setCurrentPassword] = useState(""); const [newPassword, setNewPassword] = useState(""); const [confirmPassword, setConfirmPassword] = useState(""); const [showCurrent, setShowCurrent] = useState(false); const [showNew, setShowNew] = useState(false); const [showConfirm, setShowConfirm] = useState(false); const [loading, setLoading] = useState(false); const handleSubmit = async () => { if (!currentPassword.trim()) { toast.error("Error", "Current password is required"); return; } if (!newPassword.trim()) { toast.error("Error", "New password is required"); return; } if (newPassword !== confirmPassword) { toast.error("Error", "Passwords do not match"); return; } if (newPassword.length < 6) { toast.error("Error", "Password must be at least 6 characters"); return; } setLoading(true); try { await api.auth.changePassword({ body: { currentPassword: currentPassword.trim(), newPassword: newPassword.trim(), }, }); toast.success("Success", "Password changed successfully"); nav.back(); } catch (e: any) { toast.error("Error", e?.message || "Failed to change password"); } finally { setLoading(false); } }; return ( nav.back()} className="h-10 w-10 rounded-[10px] bg-card items-center justify-center border border-border" > Change PIN Current Password setShowCurrent(!showCurrent)} className="p-1" > {showCurrent ? ( ) : ( )} New Password setShowNew(!showNew)} className="p-1"> {showNew ? ( ) : ( )} Confirm New Password setShowConfirm(!showConfirm)} className="p-1" > {showConfirm ? ( ) : ( )} ); }