import { View, Text, TouchableOpacity, Alert, TextInput, ActivityIndicator, Modal } from 'react-native' import React, { useState } from 'react' import TabBar from '../themes/TabBar' import { ChevronLeftIcon, ChevronRightIcon, CreditCardIcon, KeyIcon, UserCircleIcon, EyeIcon, EyeSlashIcon } from 'react-native-heroicons/outline' import { widthPercentageToDP as wp, heightPercentageToDP as hp } from 'react-native-responsive-screen'; import { useNavigation } from '@react-navigation/native'; import { deleteAccount, logout } from '../api'; export default function SettingScreen() { const navigation = useNavigation(); const [loading, setLoading] = useState(false); const [showDeleteModal, setShowDeleteModal] = useState(false); const [password, setPassword] = useState(''); const [showPassword, setShowPassword] = useState(false); const handleDeleteAccount = async () => { if (!password) { Alert.alert('Error', 'Please enter your password'); return; } Alert.alert( 'Delete Account', 'Are you sure you want to delete your account? This action cannot be undone.', [ { text: 'Cancel', style: 'cancel' }, { text: 'Delete', style: 'destructive', onPress: async () => { try { setLoading(true); await deleteAccount(password); await logout(); Alert.alert('Success', 'Your account has been deleted'); navigation.navigate('SignIn'); } catch (error) { console.error('Delete account error:', error); Alert.alert('Error', error.response?.data?.error || 'Failed to delete account'); } finally { setLoading(false); setShowDeleteModal(false); setPassword(''); } } } ] ); }; return ( } titleStyle={{ color: "black", fontWeight: "bold", fontSize: 20 }} prefixStyle={{ backgroundColor: "transparent" }} suffixStyle={{ backgroundColor: "white", borderWidth: 1, borderColor: "black" }} containerStyle="" suffixAction={() => navigation.goBack()} /> Notification Settings navigation.navigate('Password Manager')} className="flex-row items-center justify-between py-3" > Password Manager setShowDeleteModal(true)} className="flex-row items-center justify-between py-3" > Delete Account {/* Delete Account Modal */} setShowDeleteModal(false)} > Delete Account This action cannot be undone. Please enter your password to confirm. setShowPassword(!showPassword)}> {showPassword ? ( ) : ( )} { setShowDeleteModal(false); setPassword(''); }} className="flex-1 bg-gray-200 py-3 rounded-xl" > Cancel {loading ? ( ) : ( Delete )} ) }