modify profile
This commit is contained in:
@@ -284,9 +284,9 @@ export default function GroupScreen() {
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: { flex: 1, backgroundColor: '#f5f6fa' },
|
||||
headerContainer: { backgroundColor: '#f5f6fa', paddingTop: 40, paddingHorizontal: 16 },
|
||||
title: { fontSize: 28, fontWeight: "bold", color: "#222", marginBottom: 10 },
|
||||
searchContainer: { flexDirection: 'row', alignItems: 'center', backgroundColor: '#fff', borderRadius: 12, paddingHorizontal: 10, elevation: 2, marginBottom: 20 },
|
||||
headerContainer: { backgroundColor: '#f5f6fa', paddingHorizontal: 16 },
|
||||
title: { fontSize: 22, fontWeight: "600", color: colors.Group },
|
||||
searchContainer: { flexDirection: 'row', alignItems: 'center', backgroundColor: '#fff', borderRadius: 12, paddingHorizontal: 10, elevation: 2, marginVertical: 20 },
|
||||
searchIcon: { marginRight: 8 },
|
||||
searchInput: { flex: 1, height: 45, fontSize: 16, color: '#333' },
|
||||
sectionTitle: { fontSize: 20, fontWeight: 'bold', color: '#333', marginBottom: 12, paddingHorizontal: 16 },
|
||||
|
||||
@@ -215,9 +215,7 @@ const styles = StyleSheet.create({
|
||||
paddingBottom: 15,
|
||||
},
|
||||
title: {
|
||||
fontSize: 28,
|
||||
fontWeight: 'bold',
|
||||
color: '#1d2129',
|
||||
fontSize: 22, fontWeight: "600", color: colors.Settings
|
||||
},
|
||||
segmentedControl: {
|
||||
flexDirection: 'row',
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
TextInput,
|
||||
KeyboardAvoidingView,
|
||||
Platform,
|
||||
RefreshControl,
|
||||
} from "react-native";
|
||||
import * as Keychain from "react-native-keychain";
|
||||
import { Ionicons } from "@react-native-vector-icons/ionicons";
|
||||
@@ -23,7 +24,8 @@ import { useFocusEffect, useNavigation } from "@react-navigation/native";
|
||||
import { ApiResponse } from "../home/UserProfileStatus";
|
||||
import { BASE_URL } from "../../utils/ApiUrls";
|
||||
import AppView from "../../components/AppView";
|
||||
import { useSelector } from "react-redux";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { setUserData } from "../../redux/userSlice";
|
||||
|
||||
|
||||
|
||||
@@ -48,7 +50,7 @@ type UserProfile = {
|
||||
|
||||
const Profile = () => {
|
||||
const navigation = useNavigation<any>();
|
||||
const user1 = useSelector((state: any) => state.user);
|
||||
const dispatch = useDispatch()
|
||||
const [user, setUser] = useState<UserProfile | null>(null);
|
||||
const [fetching, setFetching] = useState(true);
|
||||
const [editing, setEditing] = useState(false);
|
||||
@@ -56,6 +58,7 @@ const Profile = () => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [statusData, setStatusData] = useState<null | { profileStatus: boolean; organizerStatus: string; role: string }>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [refreshing, setRefreshing] = useState(false);
|
||||
|
||||
const fetchUserProfile = async () => {
|
||||
try {
|
||||
@@ -82,6 +85,27 @@ const Profile = () => {
|
||||
console.log("👤 Profile Response:", result);
|
||||
if (result.status === "success") {
|
||||
setUser(result.data);
|
||||
dispatch(setUserData({
|
||||
id: result?.data.id,
|
||||
userId: result?.data.userId,
|
||||
username: result?.data.username,
|
||||
firstName: result?.data.firstName,
|
||||
lastName: result?.data.lastName,
|
||||
gender: result?.data.gender,
|
||||
mobile: result?.data.mobile,
|
||||
email: result?.data.email,
|
||||
address: result?.data.address,
|
||||
bankAccountNumber: result?.data.bankAccountNumber,
|
||||
bankName: result?.data.bankName,
|
||||
branchCode: result?.data.branchCode,
|
||||
profilePicture: result?.data.filePath, // or keep as `filePath`
|
||||
filePath: result?.data.filePath,
|
||||
imageBlob: result?.data.imageBlob,
|
||||
role: result?.data.role,
|
||||
organizerId: result?.data.organizerId,
|
||||
organizerStatus: result?.data.organizerStatus,
|
||||
profileStatus: true, // set true once profile is fetched
|
||||
}));
|
||||
} else {
|
||||
Alert.alert("Error", "Failed to fetch user profile");
|
||||
}
|
||||
@@ -290,10 +314,19 @@ const Profile = () => {
|
||||
fetchUserProfile();
|
||||
}, []);
|
||||
|
||||
const onRefresh = () => {
|
||||
setRefreshing(true);
|
||||
// Simulate a network request or data fetching
|
||||
fetchUserProfile()
|
||||
setTimeout(() => {
|
||||
setRefreshing(false);
|
||||
}, 2000); // 2 seconds delay
|
||||
};
|
||||
|
||||
console.log("user image :", user?.filePath);
|
||||
const getProfileImage = () => {
|
||||
if (user?.imageBlob) {
|
||||
return `data:image/jpeg;base64,${user.imageBlob}`;
|
||||
return `data:image/jpeg;base64,${user.imageBlob}`;
|
||||
}
|
||||
if (user?.filePath) {
|
||||
return user.filePath;
|
||||
@@ -317,7 +350,7 @@ const Profile = () => {
|
||||
<View style={styles.header}>
|
||||
<Text style={styles.headerTitle}>User Profile</Text>
|
||||
<TouchableOpacity onPress={() => confirmLogout(navigation)} style={styles.refreshButton}>
|
||||
<Ionicons name="refresh" size={24} color={'#000'} />
|
||||
<Ionicons name="log-out-outline" size={24} color={'#000'} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
<KeyboardAvoidingView
|
||||
@@ -327,6 +360,9 @@ const Profile = () => {
|
||||
<ScrollView
|
||||
contentContainerStyle={{ flexGrow: 1 }}
|
||||
keyboardShouldPersistTaps="handled"
|
||||
refreshControl={
|
||||
<RefreshControl refreshing={refreshing} onRefresh={onRefresh} />
|
||||
}
|
||||
>
|
||||
|
||||
{/* Profile Card */}
|
||||
@@ -567,9 +603,7 @@ const styles = StyleSheet.create({
|
||||
borderBottomRightRadius: 20,
|
||||
},
|
||||
headerTitle: {
|
||||
fontSize: 22,
|
||||
fontWeight: "700",
|
||||
color: "#000"
|
||||
fontSize: 22, fontWeight: "600", color: colors.Profile
|
||||
},
|
||||
refreshButton: {
|
||||
padding: 4,
|
||||
|
||||
Reference in New Issue
Block a user