feat(whole project): huge changes, huge updates
This commit is contained in:
196 files changed
+9146
-4316
No files matched your search
@@ -1,12 +1,52 @@
|
||||
import { View, Text, TextInput, TouchableOpacity } from 'react-native'
|
||||
import React from 'react'
|
||||
import { View, Text, TextInput, TouchableOpacity, Alert, ActivityIndicator } from 'react-native'
|
||||
import React, { useState } from 'react'
|
||||
import TabBar from '../themes/TabBar'
|
||||
import { ChevronLeftIcon, EyeSlashIcon } from 'react-native-heroicons/outline'
|
||||
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 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 (
|
||||
<View className={`bg-white flex-col`} style={{ height: hp("98%") }}>
|
||||
@@ -32,47 +72,86 @@ export default function PasswordManagerScreen() {
|
||||
/>
|
||||
<View className={`flex-1`}>
|
||||
<View className={`mx-4 mt-5`}>
|
||||
<Text className={` font-semibold`}>Current Password</Text>
|
||||
<Text className={`font-semibold`}>Current Password</Text>
|
||||
</View>
|
||||
<View className={`mx-4 flex-row items-center mt-2 justify-between p-2 border border-gray-300 rounded-2xl`}>
|
||||
<View className={`flex-row items-center gap-2 `}>
|
||||
<TextInput placeholder='******************* ' className={`font-semibold`} />
|
||||
<View className={`flex-row items-center gap-2 flex-1`}>
|
||||
<TextInput
|
||||
placeholder='Enter current password'
|
||||
className={`font-semibold flex-1`}
|
||||
secureTextEntry={!showCurrentPassword}
|
||||
value={passwords.currentPassword}
|
||||
onChangeText={(text) => setPasswords(prev => ({...prev, currentPassword: text}))}
|
||||
/>
|
||||
</View>
|
||||
<View className={`justify-center items-center`}>
|
||||
<EyeSlashIcon size={25} color={"black"} />
|
||||
</View>
|
||||
</View>
|
||||
<View className={`mt-3 mx-4 flex-row justify-end`}>
|
||||
<Text className={`text-left border-b text-primary border-primary font-semibold`}>Forgot Passwords ?</Text>
|
||||
</View>
|
||||
<View className={`mx-4 mt-5`}>
|
||||
<Text className={` font-semibold`}>New Password</Text>
|
||||
</View>
|
||||
<View className={`mx-4 flex-row items-center mt-2 justify-between p-2 border border-gray-300 rounded-2xl`}>
|
||||
<View className={`flex-row items-center gap-2 `}>
|
||||
<TextInput placeholder='******************* ' className={`font-semibold`} />
|
||||
</View>
|
||||
<View className={`justify-center items-center`}>
|
||||
<EyeSlashIcon size={25} color={"black"} />
|
||||
</View>
|
||||
</View>
|
||||
<View className={`mx-4 mt-5`}>
|
||||
<Text className={` font-semibold`}>Conform New Password</Text>
|
||||
</View>
|
||||
<View className={`mx-4 flex-row items-center mt-2 justify-between p-2 border border-gray-300 rounded-2xl`}>
|
||||
<View className={`flex-row items-center gap-2 `}>
|
||||
<TextInput placeholder='******************* ' className={`font-semibold`} />
|
||||
</View>
|
||||
<View className={`justify-center items-center`}>
|
||||
<EyeSlashIcon size={25} color={"black"} />
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className={` bg-white px-4 rounded-tl-2xl border rounded-tr-2xl gap-3 py-3 border-gray-300`}>
|
||||
<TouchableOpacity className={`border rounded-full bg-primary flex-row justify-center items-center `} style={{ height: hp('5%') }}>
|
||||
<Text className={`text-white text-lg font-semibold`}>Change Password</Text>
|
||||
<TouchableOpacity onPress={() => setShowCurrentPassword(!showCurrentPassword)}>
|
||||
{showCurrentPassword ? (
|
||||
<EyeIcon size={25} color={"black"} />
|
||||
) : (
|
||||
<EyeSlashIcon size={25} color={"black"} />
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
|
||||
<View className={`mx-4 mt-5`}>
|
||||
<Text className={`font-semibold`}>New Password</Text>
|
||||
</View>
|
||||
<View className={`mx-4 flex-row items-center mt-2 justify-between p-2 border border-gray-300 rounded-2xl`}>
|
||||
<View className={`flex-row items-center gap-2 flex-1`}>
|
||||
<TextInput
|
||||
placeholder='Enter new password'
|
||||
className={`font-semibold flex-1`}
|
||||
secureTextEntry={!showNewPassword}
|
||||
value={passwords.newPassword}
|
||||
onChangeText={(text) => setPasswords(prev => ({...prev, newPassword: text}))}
|
||||
/>
|
||||
</View>
|
||||
<TouchableOpacity onPress={() => setShowNewPassword(!showNewPassword)}>
|
||||
{showNewPassword ? (
|
||||
<EyeIcon size={25} color={"black"} />
|
||||
) : (
|
||||
<EyeSlashIcon size={25} color={"black"} />
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
|
||||
<View className={`mx-4 mt-5`}>
|
||||
<Text className={`font-semibold`}>Confirm New Password</Text>
|
||||
</View>
|
||||
<View className={`mx-4 flex-row items-center mt-2 justify-between p-2 border border-gray-300 rounded-2xl`}>
|
||||
<View className={`flex-row items-center gap-2 flex-1`}>
|
||||
<TextInput
|
||||
placeholder='Confirm new password'
|
||||
className={`font-semibold flex-1`}
|
||||
secureTextEntry={!showConfirmPassword}
|
||||
value={passwords.confirmPassword}
|
||||
onChangeText={(text) => setPasswords(prev => ({...prev, confirmPassword: text}))}
|
||||
/>
|
||||
</View>
|
||||
<TouchableOpacity onPress={() => setShowConfirmPassword(!showConfirmPassword)}>
|
||||
{showConfirmPassword ? (
|
||||
<EyeIcon size={25} color={"black"} />
|
||||
) : (
|
||||
<EyeSlashIcon size={25} color={"black"} />
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className={`bg-white px-4 rounded-tl-2xl border rounded-tr-2xl gap-3 py-3 border-gray-300`}>
|
||||
<TouchableOpacity
|
||||
className={`border rounded-full bg-primary flex-row justify-center items-center`}
|
||||
style={{ height: hp('5%') }}
|
||||
onPress={handlePasswordChange}
|
||||
disabled={loading}
|
||||
>
|
||||
{loading ? (
|
||||
<ActivityIndicator color="white" />
|
||||
) : (
|
||||
<Text className={`text-white text-lg font-semibold`}>Change Password</Text>
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user