diff --git a/src/components/common/Header.tsx b/src/components/common/Header.tsx index 9ce3fd0..6b932b3 100644 --- a/src/components/common/Header.tsx +++ b/src/components/common/Header.tsx @@ -18,8 +18,8 @@ const Header: React.FC = ({ showBack = true, onBackPress, rightAction, - titleColor = colors.primary, - arrowColor = colors.primary + titleColor = '#000', + arrowColor = '#000' }) => { const navigation = useNavigation(); @@ -33,12 +33,12 @@ const Header: React.FC = ({ return ( - {/* {showBack && ( + {showBack && ( - )} */} - {title} + )} + {title} {rightAction} ); @@ -57,6 +57,6 @@ const styles = StyleSheet.create({ headerTitle: { fontSize: 18, fontWeight: "600", - textTransform:'uppercase' + textTransform: "capitalize", }, }); diff --git a/src/screens/home/Home.tsx b/src/screens/home/Home.tsx index 0318a7f..3492ca7 100644 --- a/src/screens/home/Home.tsx +++ b/src/screens/home/Home.tsx @@ -66,8 +66,8 @@ const userActions: ActionItem[] = [ const Home: React.FC = () => { const user = useSelector((state: any) => state.user); const notifications = useSelector( - (state: any) => state.notifications.notifications - ); + (state: any) => state.notifications.notifications + ); const navigation = useNavigation(); const dispatch = useDispatch(); @@ -97,7 +97,6 @@ const Home: React.FC = () => { } else if (item.action === "TRANSACTION") { navigation.navigate("TransactionList" as never); } else if (item.action === "NAVIGATE_CREATE_GROUP") { - navigation.navigate("GroupCreation" as never); } else { ToastAndroid.show(`Unknown action: ${item.title}`, ToastAndroid.SHORT); @@ -133,13 +132,12 @@ const Home: React.FC = () => { {user.firstName || apiUser?.firstName || 'User'} navigation.navigate("Notification" as never)}> - {/* */} - {unreadCount > 0 ? unreadCount : ''} + {unreadCount > 0 ? unreadCount : ''} - + Quick Actions @@ -178,13 +176,6 @@ const styles = StyleSheet.create({ fontWeight: 'bold', color: colors.textDark, }, - profileImage: { - width: 50, - height: 50, - borderRadius: 25, - borderColor: colors.pastelPink, // Using pastelPink for border - borderWidth: 2, - }, sectionTitle: { fontSize: 20, fontWeight: '600', diff --git a/src/screens/home/UserProfileStatus.tsx b/src/screens/home/UserProfileStatus.tsx index 1d0f908..7592dab 100644 --- a/src/screens/home/UserProfileStatus.tsx +++ b/src/screens/home/UserProfileStatus.tsx @@ -1,249 +1,314 @@ -import React, { use, useCallback, useEffect, useState } from "react"; +import React, { useCallback, useEffect, useState } from "react"; import { - StyleSheet, - Text, - View, - ActivityIndicator, - TouchableOpacity, - Modal, - Alert, + StyleSheet, + Text, + View, + TouchableOpacity, + Modal, + ToastAndroid, + Image, + Animated, } from "react-native"; import * as Keychain from "react-native-keychain"; import { useFocusEffect, useNavigation } from "@react-navigation/native"; import { PUT_USER_STATUS } from "../../utils/ApiUrls"; import colors from "../../components/colors"; import LinearGradient from "react-native-linear-gradient"; -import Ionicons from "@react-native-vector-icons/ionicons"; +import {Ionicons} from "@react-native-vector-icons/ionicons"; export type ApiResponse = { - message: string; - status: string; - statusCode: number; - data: { - role: string; - organizerStatus: string; - profileStatus: boolean; - }; + message: string; + status: string; + statusCode: number; + data: { + role: string; + organizerStatus: string; + profileStatus: boolean; + }; }; +type UserProfileStatusProps = { + profileImage?: { uri: string }; +}; -const UserProfileStatus: React.FC = () => { - const navigation = useNavigation(); - const [loading, setLoading] = useState(true); - const [statusData, setStatusData] = useState(null); - const [error, setError] = useState(null); - const [showModal, setShowModal] = useState(false); - const [intervalId, setIntervalId] = useState(null); +const UserProfileStatus: React.FC = ({ profileImage }) => { + const navigation = useNavigation(); + const [loading, setLoading] = useState(true); + const [statusData, setStatusData] = useState(null); + const [showModal, setShowModal] = useState(false); + const [intervalId, setIntervalId] = useState(null); + const fadeAnim = useState(new Animated.Value(0))[0]; - const userStatus = async () => { - try { - const credentials = await Keychain.getGenericPassword(); - if (!credentials) { - ToastAndroid.show('You are not logged in', ToastAndroid.SHORT); - return; - } - const token = credentials.password; + const userStatus = async () => { + try { + const credentials = await Keychain.getGenericPassword(); + if (!credentials) { + ToastAndroid.show("You are not logged in", ToastAndroid.SHORT); + return; + } + const token = credentials.password; - setLoading(true); - setError(null); - const response = await fetch(PUT_USER_STATUS, { - method: "GET", - headers: { - Accept: "*/*", - Authorization: `Bearer ${token}`, - }, - }); + setLoading(true); + const response = await fetch(PUT_USER_STATUS, { + method: "GET", + headers: { + Accept: "*/*", + Authorization: `Bearer ${token}`, + }, + }); - const json: ApiResponse = await response.json(); - - console.log("Profile Status :", json); - if (json.status === "success") { - setStatusData(json.data); - - if (json.data.profileStatus === false) { - setShowModal(true); - } - } else { - setError(json.message || "Failed to fetch status"); - } - } catch (err) { - setError("Something went wrong. Please try again."); - } finally { - setLoading(false); + const json: ApiResponse = await response.json(); + if (json.status === "success") { + setStatusData(json.data); + if (json.data.profileStatus === false) { + setShowModal(true); } - }; + } else { + ToastAndroid.show("Failed to fetch status", ToastAndroid.SHORT); + } + } catch { + ToastAndroid.show("Something went wrong", ToastAndroid.SHORT); + } finally { + setLoading(false); + } + }; - useFocusEffect( - useCallback(() => { - userStatus(); - }, []) - ); + useFocusEffect( + useCallback(() => { + userStatus(); + }, []) + ); - useEffect(() => { - if (statusData && statusData.profileStatus === false) { - const id = setInterval(() => { - setShowModal(true); - }, 5000); - setIntervalId(id); - return () => clearInterval(id); - } - }, [statusData]); + useEffect(() => { + Animated.timing(fadeAnim, { + toValue: 1, + duration: 600, + useNativeDriver: true, + }).start(); + }, []); - const handleGoToProfile = () => { - // Stop modal repetition - if (intervalId) { - clearInterval(intervalId); - setIntervalId(null); - } + const handleGoToProfile = () => { + if (intervalId) { + clearInterval(intervalId); + setIntervalId(null); + } + setShowModal(false); + navigation.navigate("Profile" as never); + }; - setShowModal(false); + const handlePress = (label: string) => { + ToastAndroid.show(`${label} clicked`, ToastAndroid.SHORT); + }; - // Option 1: Mark profile as completed temporarily (so condition stops) - setStatusData(prev => (prev ? { ...prev, profileStatus: true } : prev)); + return ( + + + {/* LEFT SECTION */} + + Profile Overview - // Navigate to Profile screen - navigation.navigate("Profile" as never); - }; - - return ( - - {/* Welcome Back 👋 */} - - - - Profile Status - Role: {statusData?.role} - Organizer: {statusData?.organizerStatus} - - Profile Completed: {statusData?.profileStatus ? "Yes ✅" : "No ❌"} - - - - - - - {/* Custom Modal */} - {showModal && ( - setShowModal(false)} + + + {[ + "Role", + "Total Active Groups", + "Total Joined Groups", + "Total Created Groups", + "Total Due Payment", + "Total Completed Groups", + ].map((label, i) => ( + handlePress(label)} > - - - Complete Your Profile - - Your profile is incomplete. Please update your details to continue. - + {label} + + ))} + - - Go to Profile - + + {[ + statusData?.role || "-", + "5", + "3", + "2", + "₹1500", + "4", + ].map((value, i) => ( + handlePress(value)} + > + {value} + + ))} + + - { - if (intervalId) { - clearInterval(intervalId); - setIntervalId(null); - } - - setShowModal(false); - }} - > - Close - - - - - )} + + + Organizer: {statusData?.organizerStatus || "-"} + + + Profile Completed:{" "} + {statusData?.profileStatus ? "Yes ✅" : "No ❌"} + + - ); -}; + {/* RIGHT SECTION - IMAGE */} + {/* navigation.navigate("Profile" as never)} + activeOpacity={0.8} + > + {profileImage ? ( + + ) : ( + + )} + */} + + + {/* Modal */} + {showModal && ( + + + + + Complete Your Profile + + Your profile is incomplete. Please update your details to continue. + + + + Go to Profile + + + setShowModal(false)} + > + Later + + + + + )} + + ); +}; export default UserProfileStatus; const styles = StyleSheet.create({ - container: { - // flex: 1, - // padding: 16, - // backgroundColor: "#f5f7fb", - }, - centered: { - flex: 1, - justifyContent: "center", - alignItems: "center", - }, - title: { - fontSize: 22, - fontWeight: "700", - marginBottom: 20, - }, - card: { - backgroundColor: "#fff", - padding: 16, - borderRadius: 12, - elevation: 3, - shadowOpacity: 0.1, - shadowRadius: 6, - marginBottom: 10, - justifyContent:'space-between', - flexDirection:'row' - }, - cardTitle: { - fontSize: 18, - fontWeight: "600", - marginBottom: 10, - color: '#fff' - }, - button: { - backgroundColor: "#007AFF", - paddingVertical: 10, - paddingHorizontal: 20, - borderRadius: 8, - alignItems: "center", - }, - buttonText: { - color: "#fff", - fontWeight: "600", - }, - errorText: { - color: "red", - fontSize: 16, - marginBottom: 12, - }, - modalOverlay: { - flex: 1, - backgroundColor: "rgba(0,0,0,0.4)", - justifyContent: "center", - alignItems: "center", - }, - modalBox: { - width: "85%", - backgroundColor: "#fff", - borderRadius: 16, - padding: 20, - alignItems: "center", - elevation: 5, - }, - modalTitle: { - fontSize: 20, - fontWeight: "700", - marginBottom: 10, - color: colors.primary, - }, - modalText: { - fontSize: 14, - color: "#444", - textAlign: "center", - marginBottom: 20, - }, + container: { + margin: 12, + }, + card: { + flexDirection: "row", + justifyContent: "space-between", + alignItems: "center", + borderRadius: 16, + padding: 18, + elevation: 5, + shadowColor: "#000", + shadowOpacity: 0.2, + shadowRadius: 6, + }, + header: { + fontSize: 20, + fontWeight: "700", + color: "#fff", + marginBottom: 10, + }, + leftSection: { + flex: 1, + }, + infoRow: { + flexDirection: "row", + justifyContent: "space-between", + marginBottom: 10, + }, + infoLabelBox: { + marginBottom: 6, + }, + infoLabel: { + color: "rgba(255,255,255,0.8)", + fontSize: 13, + }, + infoValueBox: { + marginBottom: 6, + alignItems: "flex-end", + }, + infoValue: { + color: "#fff", + fontWeight: "600", + fontSize: 13, + }, + statusBox: { + backgroundColor: "rgba(255,255,255,0.15)", + padding: 10, + borderRadius: 8, + }, + statusText: { + color: "#fff", + fontSize: 13, + }, + avatar: { + width: 80, + height: 80, + borderRadius: 40, + borderWidth: 2, + borderColor: "#fff", + }, + modalOverlay: { + flex: 1, + backgroundColor: "rgba(0,0,0,0.5)", + justifyContent: "center", + alignItems: "center", + }, + modalBox: { + width: "85%", + backgroundColor: "#fff", + borderRadius: 18, + padding: 20, + alignItems: "center", + elevation: 6, + }, + modalTitle: { + fontSize: 20, + fontWeight: "700", + color: colors.primary, + marginVertical: 8, + }, + modalText: { + textAlign: "center", + color: "#444", + fontSize: 14, + marginBottom: 18, + }, + button: { + backgroundColor: colors.primary, + paddingVertical: 10, + paddingHorizontal: 30, + borderRadius: 8, + marginTop: 8, + }, + buttonText: { + color: "#fff", + fontWeight: "600", + }, + secondaryButton: { + backgroundColor: "#eee", + }, + secondaryText: { + color: "#333", + }, });