Merge branch 'feature_contact' of https://git.zeptic.in/abintoppo_lincpay/CircleCollect into feature_profile

This commit is contained in:
Abin Toppo
2025-09-19 16:00:11 +05:30
3 changed files with 45 additions and 13 deletions
+3 -3
View File
@@ -284,9 +284,9 @@ export default function GroupScreen() {
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { flex: 1, backgroundColor: '#f5f6fa' }, container: { flex: 1, backgroundColor: '#f5f6fa' },
headerContainer: { backgroundColor: '#f5f6fa', paddingTop: 40, paddingHorizontal: 16 }, headerContainer: { backgroundColor: '#f5f6fa', paddingHorizontal: 16 },
title: { fontSize: 28, fontWeight: "bold", color: "#222", marginBottom: 10 }, title: { fontSize: 22, fontWeight: "600", color: colors.Group },
searchContainer: { flexDirection: 'row', alignItems: 'center', backgroundColor: '#fff', borderRadius: 12, paddingHorizontal: 10, elevation: 2, marginBottom: 20 }, searchContainer: { flexDirection: 'row', alignItems: 'center', backgroundColor: '#fff', borderRadius: 12, paddingHorizontal: 10, elevation: 2, marginVertical: 20 },
searchIcon: { marginRight: 8 }, searchIcon: { marginRight: 8 },
searchInput: { flex: 1, height: 45, fontSize: 16, color: '#333' }, searchInput: { flex: 1, height: 45, fontSize: 16, color: '#333' },
sectionTitle: { fontSize: 20, fontWeight: 'bold', color: '#333', marginBottom: 12, paddingHorizontal: 16 }, sectionTitle: { fontSize: 20, fontWeight: 'bold', color: '#333', marginBottom: 12, paddingHorizontal: 16 },
+1 -3
View File
@@ -215,9 +215,7 @@ const styles = StyleSheet.create({
paddingBottom: 15, paddingBottom: 15,
}, },
title: { title: {
fontSize: 28, fontSize: 22, fontWeight: "600", color: colors.Settings
fontWeight: 'bold',
color: '#1d2129',
}, },
segmentedControl: { segmentedControl: {
flexDirection: 'row', flexDirection: 'row',
+41 -7
View File
@@ -12,6 +12,7 @@ import {
TextInput, TextInput,
KeyboardAvoidingView, KeyboardAvoidingView,
Platform, Platform,
RefreshControl,
} from "react-native"; } from "react-native";
import * as Keychain from "react-native-keychain"; import * as Keychain from "react-native-keychain";
import { Ionicons } from "@react-native-vector-icons/ionicons"; 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 { ApiResponse } from "../home/UserProfileStatus";
import { BASE_URL } from "../../utils/ApiUrls"; import { BASE_URL } from "../../utils/ApiUrls";
import AppView from "../../components/AppView"; 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 Profile = () => {
const navigation = useNavigation<any>(); const navigation = useNavigation<any>();
const user1 = useSelector((state: any) => state.user); const dispatch = useDispatch()
const [user, setUser] = useState<UserProfile | null>(null); const [user, setUser] = useState<UserProfile | null>(null);
const [fetching, setFetching] = useState(true); const [fetching, setFetching] = useState(true);
const [editing, setEditing] = useState(false); const [editing, setEditing] = useState(false);
@@ -56,6 +58,7 @@ const Profile = () => {
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [statusData, setStatusData] = useState<null | { profileStatus: boolean; organizerStatus: string; role: string }>(null); const [statusData, setStatusData] = useState<null | { profileStatus: boolean; organizerStatus: string; role: string }>(null);
const [error, setError] = useState<string | null>(null); const [error, setError] = useState<string | null>(null);
const [refreshing, setRefreshing] = useState(false);
const fetchUserProfile = async () => { const fetchUserProfile = async () => {
try { try {
@@ -82,6 +85,27 @@ const Profile = () => {
console.log("👤 Profile Response:", result); console.log("👤 Profile Response:", result);
if (result.status === "success") { if (result.status === "success") {
setUser(result.data); 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 { } else {
Alert.alert("Error", "Failed to fetch user profile"); Alert.alert("Error", "Failed to fetch user profile");
} }
@@ -290,10 +314,19 @@ const Profile = () => {
fetchUserProfile(); 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); console.log("user image :", user?.filePath);
const getProfileImage = () => { const getProfileImage = () => {
if (user?.imageBlob) { if (user?.imageBlob) {
return `data:image/jpeg;base64,${user.imageBlob}`; return `data:image/jpeg;base64,${user.imageBlob}`;
} }
if (user?.filePath) { if (user?.filePath) {
return user.filePath; return user.filePath;
@@ -317,7 +350,7 @@ const Profile = () => {
<View style={styles.header}> <View style={styles.header}>
<Text style={styles.headerTitle}>User Profile</Text> <Text style={styles.headerTitle}>User Profile</Text>
<TouchableOpacity onPress={() => confirmLogout(navigation)} style={styles.refreshButton}> <TouchableOpacity onPress={() => confirmLogout(navigation)} style={styles.refreshButton}>
<Ionicons name="refresh" size={24} color={'#000'} /> <Ionicons name="log-out-outline" size={24} color={'#000'} />
</TouchableOpacity> </TouchableOpacity>
</View> </View>
<KeyboardAvoidingView <KeyboardAvoidingView
@@ -327,6 +360,9 @@ const Profile = () => {
<ScrollView <ScrollView
contentContainerStyle={{ flexGrow: 1 }} contentContainerStyle={{ flexGrow: 1 }}
keyboardShouldPersistTaps="handled" keyboardShouldPersistTaps="handled"
refreshControl={
<RefreshControl refreshing={refreshing} onRefresh={onRefresh} />
}
> >
{/* Profile Card */} {/* Profile Card */}
@@ -567,9 +603,7 @@ const styles = StyleSheet.create({
borderBottomRightRadius: 20, borderBottomRightRadius: 20,
}, },
headerTitle: { headerTitle: {
fontSize: 22, fontSize: 22, fontWeight: "600", color: colors.Profile
fontWeight: "700",
color: "#000"
}, },
refreshButton: { refreshButton: {
padding: 4, padding: 4,