import { View, Text, TextInput, TouchableOpacity, Alert, ActivityIndicator } from 'react-native' import React, { useState } from 'react' import TabBar from '../themes/TabBar' import { ChevronLeftIcon, EyeSlashIcon, EyeIcon } from 'react-native-heroicons/outline' import { widthPercentageToDP as wp, heightPercentageToDP as hp } from 'react-native-responsive-screen'; import { useNavigation } from '@react-navigation/native'; import { updatePassword } from '../api'; export default function PasswordManagerScreen() { const navigation = useNavigation(); const [loading, setLoading] = useState(false); const [showCurrentPassword, setShowCurrentPassword] = useState(false); const [showNewPassword, setShowNewPassword] = useState(false); const [showConfirmPassword, setShowConfirmPassword] = useState(false); const [passwords, setPasswords] = useState({ currentPassword: '', newPassword: '', confirmPassword: '' }); const handlePasswordChange = async () => { // Validate passwords if (!passwords.currentPassword || !passwords.newPassword || !passwords.confirmPassword) { Alert.alert('Error', 'Please fill in all password fields'); return; } if (passwords.newPassword !== passwords.confirmPassword) { Alert.alert('Error', 'New passwords do not match'); return; } if (passwords.newPassword.length < 8) { Alert.alert('Error', 'New password must be at least 8 characters long'); return; } try { setLoading(true); await updatePassword(passwords.currentPassword, passwords.newPassword); Alert.alert('Success', 'Password updated successfully'); navigation.goBack(); } catch (error) { console.error('Password update error:', error); Alert.alert('Error', error.response?.data?.error || 'Failed to update password'); } finally { setLoading(false); } }; return ( } titleStyle={{ color: "black", fontWeight: "bold", fontSize: 20 }} prefixStyle={{ backgroundColor: "transparent" }} suffixStyle={{ backgroundColor: "white", borderWidth: 1, borderColor: "black" }} containerStyle="" suffixAction={() => navigation.goBack()} /> Current Password setPasswords(prev => ({...prev, currentPassword: text}))} /> setShowCurrentPassword(!showCurrentPassword)}> {showCurrentPassword ? ( ) : ( )} New Password setPasswords(prev => ({...prev, newPassword: text}))} /> setShowNewPassword(!showNewPassword)}> {showNewPassword ? ( ) : ( )} Confirm New Password setPasswords(prev => ({...prev, confirmPassword: text}))} /> setShowConfirmPassword(!showConfirmPassword)}> {showConfirmPassword ? ( ) : ( )} {loading ? ( ) : ( Change Password )} ) }