From 04f91c0b03dc8313db4949c13aa5d6dd72c27ab5 Mon Sep 17 00:00:00 2001 From: Jaanu423 Date: Fri, 19 Sep 2025 15:58:21 +0530 Subject: [PATCH] modify profile --- src/screens/GroupScreen.tsx | 6 +-- src/screens/management/ManagementScreen.tsx | 4 +- src/screens/profile/Profile.tsx | 48 ++++++++++++++++++--- 3 files changed, 45 insertions(+), 13 deletions(-) diff --git a/src/screens/GroupScreen.tsx b/src/screens/GroupScreen.tsx index 1698a64..4d49234 100644 --- a/src/screens/GroupScreen.tsx +++ b/src/screens/GroupScreen.tsx @@ -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 }, diff --git a/src/screens/management/ManagementScreen.tsx b/src/screens/management/ManagementScreen.tsx index e3bb4c1..17232f2 100644 --- a/src/screens/management/ManagementScreen.tsx +++ b/src/screens/management/ManagementScreen.tsx @@ -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', diff --git a/src/screens/profile/Profile.tsx b/src/screens/profile/Profile.tsx index 97df1a7..f9f9d07 100644 --- a/src/screens/profile/Profile.tsx +++ b/src/screens/profile/Profile.tsx @@ -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(); - const user1 = useSelector((state: any) => state.user); + const dispatch = useDispatch() const [user, setUser] = useState(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); const [error, setError] = useState(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 = () => { User Profile confirmLogout(navigation)} style={styles.refreshButton}> - + { + } > {/* 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,