correct issues

This commit is contained in:
Jaanu423
2025-10-13 14:00:13 +05:30
parent ae35611bdb
commit 848032768c
9 changed files with 105 additions and 105 deletions
+4 -2
View File
@@ -46,12 +46,14 @@ export type RootStackParamList = {
TransactionList: undefined TransactionList: undefined
RandomSelectUserScreen: { groupId: string | number, cycleNumber: number }; RandomSelectUserScreen: { groupId: string | number, cycleNumber: number };
Notification: undefined; Notification: undefined;
NotificationRedirection:{ data: any }; NotificationRedirection: { data: any };
Management: Management:
| { actionTab: "My Groups" } | { actionTab: "My Groups" }
| { actionTab1: "Joined Groups" } | { actionTab1: "Joined Groups" }
| { actionTab2: "Requests" } | { actionTab2: "Requests" }
| { actionTab3: "Your Requests" }; | { actionTab3: "Your Requests" }
| { groupId: string | number; }
}; };
const Stack = createNativeStackNavigator<RootStackParamList>(); const Stack = createNativeStackNavigator<RootStackParamList>();
+1
View File
@@ -32,6 +32,7 @@ export type RootStackParamList = {
ManageJoinedGroup: { groupId: string | number }; ManageJoinedGroup: { groupId: string | number };
Invite: { groupId: string | number; code: string | number }; Invite: { groupId: string | number; code: string | number };
ManagementTabs:any ManagementTabs:any
NotificationRedirection: { data: any };
}; };
+3 -2
View File
@@ -9,6 +9,7 @@ import {
TouchableOpacity, TouchableOpacity,
Alert, Alert,
Image, Image,
ToastAndroid,
} from "react-native"; } from "react-native";
import { useNavigation } from "@react-navigation/native"; import { useNavigation } from "@react-navigation/native";
import { CustomInput } from "../components/common/Custom"; import { CustomInput } from "../components/common/Custom";
@@ -75,8 +76,8 @@ export default function GroupCreationForm() {
console.log("Reviewing Payload:", payload); console.log("Reviewing Payload:", payload);
navigation.navigate("GroupReview", { form: payload }); navigation.navigate("GroupReview", { form: payload });
} else { } else {
Alert.alert("Incomplete Form", "Please fill out all required fields correctly."); ToastAndroid.show('Please fill out all required fields correctly.', ToastAndroid.SHORT);
setErrors('') setErrors('');
} }
}; };
+3 -3
View File
@@ -12,6 +12,7 @@ import {
ScrollView, ScrollView,
Alert, Alert,
RefreshControl, RefreshControl,
ToastAndroid,
} from "react-native"; } from "react-native";
import { FAB } from "react-native-paper"; import { FAB } from "react-native-paper";
import { Ionicons } from "@react-native-vector-icons/ionicons"; import { Ionicons } from "@react-native-vector-icons/ionicons";
@@ -176,13 +177,12 @@ export default function GroupScreen() {
console.log("JOIN_GROUP_URL response:", res); console.log("JOIN_GROUP_URL response:", res);
if (res.statusCode === 200) { if (res.statusCode === 200) {
Alert.alert("Success", "You requested to join the group."); ToastAndroid.show('You requested to join the group.', ToastAndroid.SHORT);
} else { } else {
// Alert.alert("Error", res.message || "Failed to join group."); ToastAndroid.show(res.message || "Failed to join group.", ToastAndroid.SHORT);
} }
} catch (error) { } catch (error) {
console.error("Join Group Error:", error); console.error("Join Group Error:", error);
// Alert.alert("Error", "An unexpected error occurred.");
} }
}; };
+1 -5
View File
@@ -18,14 +18,11 @@ const NotificationRedirection: React.FC = () => {
// This effect runs once when the component mounts // This effect runs once when the component mounts
if (data) { if (data) {
console.log('🔄 Processing notification data:', data); console.log('🔄 Processing notification data:', data);
// --- Your Redirection Logic Goes Here --- // --- Your Redirection Logic Goes Here ---
// Use the 'data' object to decide where to go. // Use the 'data' object to decide where to go.
// For this example, we'll navigate based on 'msgType'. // For this example, we'll navigate based on 'msgType'.
let destination: keyof RootStackParamList = 'Home'; // Default destination let destination: keyof RootStackParamList = 'Home'; // Default destination
let params: object | undefined = undefined; let params: object | undefined = undefined;
switch (data.msgType) { switch (data.msgType) {
case 'JOIN_REQUEST': case 'JOIN_REQUEST':
destination = 'Home'; destination = 'Home';
@@ -62,10 +59,9 @@ const NotificationRedirection: React.FC = () => {
// Keep the default destination as 'Home' // Keep the default destination as 'Home'
break; break;
} }
console.log(`➡ Redirecting to ${destination} with params:`, params);
// Use replace to prevent the user from navigating back to this loading screen // Use replace to prevent the user from navigating back to this loading screen
navigation.replace(destination, params); navigation.replace(destination, params);
} else { } else {
// If no data is passed for some reason, just go to the home screen // If no data is passed for some reason, just go to the home screen
console.warn('⚠ No data found in notification, redirecting to Home.'); console.warn('⚠ No data found in notification, redirecting to Home.');
+11 -8
View File
@@ -23,6 +23,7 @@ const CustomDropdown = ({ items, selectedValue, onValueChange, placeholder = "Se
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const selectedLabel = items.find((item:any) => item.value === selectedValue)?.label || placeholder; const selectedLabel = items.find((item:any) => item.value === selectedValue)?.label || placeholder;
return ( return (
<View style={styles.dropdownWrapper}> <View style={styles.dropdownWrapper}>
<TouchableOpacity onPress={() => setOpen(true)} style={styles.dropdownHeader}> <TouchableOpacity onPress={() => setOpen(true)} style={styles.dropdownHeader}>
@@ -64,6 +65,8 @@ const CustomDropdown = ({ items, selectedValue, onValueChange, placeholder = "Se
const GroupDetails = () => { const GroupDetails = () => {
const route = useRoute<any>(); const route = useRoute<any>();
console.log(" route id : ", route)
const [memberData, setMemberData] = useState([]); const [memberData, setMemberData] = useState([]);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [openModal, setOpenModal] = useState(false); const [openModal, setOpenModal] = useState(false);
@@ -85,7 +88,7 @@ const GroupDetails = () => {
const getCycleDashboard = async () => { const getCycleDashboard = async () => {
try { try {
const response = await apiCall(`${BASE_URL}payments/groups/${group.id}/cycle-dashboard`, "GET") as any; const response = await apiCall(`${BASE_URL}payments/groups/${group.id || route?.params?.groupId}/cycle-dashboard`, "GET") as any;
const responseData = response.data; const responseData = response.data;
setCycleDashboardData(responseData); setCycleDashboardData(responseData);
@@ -106,7 +109,7 @@ const GroupDetails = () => {
const fetchGroupDetails = async () => { const fetchGroupDetails = async () => {
try { try {
const res = await apiCall(`${GROUP_ALL_MEMBER}?groupId=${group.id}`, "GET") as any; const res = await apiCall(`${GROUP_ALL_MEMBER}?groupId=${group.id || route?.params?.groupId}`, "GET") as any;
console.log("Group Members Response: ", res); console.log("Group Members Response: ", res);
setMemberData(res.data); setMemberData(res.data);
} catch (error: any) { } catch (error: any) {
@@ -116,7 +119,7 @@ const GroupDetails = () => {
const handleContribution = async () => { const handleContribution = async () => {
try { try {
const res = await apiCall(`${CONTRIBUTE}${group.id}/calculate-contribution`, 'GET') as any; const res = await apiCall(`${CONTRIBUTE}${group.id || route?.params?.groupId}/calculate-contribution`, 'GET') as any;
setPayable(res.data); setPayable(res.data);
} catch (error) { } catch (error) {
console.log("Error in handleContribution: ", error); console.log("Error in handleContribution: ", error);
@@ -131,13 +134,13 @@ const GroupDetails = () => {
getCycleDashboard() getCycleDashboard()
]); ]);
setLoading(false); setLoading(false);
}, [group.id]); }, [group.id || route?.params?.groupId]);
useEffect(() => { useEffect(() => {
if (group.id) { if (group.id || route?.params?.groupId) {
fetchAllData(); fetchAllData();
} }
}, [group.id, fetchAllData]); }, [group.id || route?.params?.groupId, fetchAllData]);
const onRefresh = useCallback(async () => { const onRefresh = useCallback(async () => {
setRefreshing(true); setRefreshing(true);
@@ -169,8 +172,8 @@ const GroupDetails = () => {
} }
contentContainerStyle={styles.scrollContent} contentContainerStyle={styles.scrollContent}
> >
<Header title={group.name} /> <Header title={group.name || route.name} />
<Text style={styles.description}>{group.description}</Text> <Text style={styles.description}>{group.description || route.name}</Text>
<View style={styles.statsRow}> <View style={styles.statsRow}>
<View style={styles.statBox}> <View style={styles.statBox}>
+68 -67
View File
@@ -44,22 +44,20 @@ const Notification = () => {
dispatch(clearAllNotifications()); dispatch(clearAllNotifications());
}; };
const handleMarkAsRead = (messageId: string, screen: string) => { const handleMarkAsRead = (messageId: string, screen: string, groupId: string, cycleNumber: string, contributionId: string) => {
console.log("screen type : ", screen); console.log("screen type : ", screen);
handleMarkAsReadAndNavigate( handleMarkAsReadAndNavigate(
messageId, messageId,
screen, screen,
{ {
// Pass additional parameters based on notification type groupId: groupId,
groupId: 'ebc27862-acde-4129-b12c-fd4c2966e858', cycleNumber,
cycleNumber: '1', contributionId,
contributionId: '12345', actionTab3: 'Your Requests',
actionTab3: 'Your Requests' ,
actionTab1: 'Joined Groups', actionTab1: 'Joined Groups',
GroupDetails: { GroupDetails: {
item: {} item: {}
}, },
// etc.
} }
); );
}; };
@@ -240,74 +238,77 @@ const Notification = () => {
keyExtractor={(item) => item.messageId} keyExtractor={(item) => item.messageId}
showsVerticalScrollIndicator={false} showsVerticalScrollIndicator={false}
contentContainerStyle={styles.listContainer} contentContainerStyle={styles.listContainer}
renderItem={({ item }) => ( renderItem={({ item }) => {
<TouchableOpacity console.log("noti items : ", item)
onPress={() => handleMarkAsRead(item.messageId, item?.data?.msgType)} return (
activeOpacity={0.7} <TouchableOpacity
> onPress={() => handleMarkAsRead(item.messageId, item?.data?.msgType, item?.data?.groupId, item?.data?.cycleNumber, item?.data?.contributionId)}
<LinearGradient activeOpacity={0.7}
colors={item.read ? ['#f8f9fa', '#e9ecef'] : ['#ffffff', '#f8f9fa']} >
style={[ <LinearGradient
styles.notificationCard, colors={item.read ? ['#f8f9fa', '#e9ecef'] : ['#ffffff', '#f8f9fa']}
!item.read && styles.unreadNotification, { borderLeftColor: getNotificationColor(item.data.msgType) } style={[
]}> styles.notificationCard,
<View style={styles.notificationContent}> !item.read && styles.unreadNotification, { borderLeftColor: getNotificationColor(item.data.msgType) }
{/* Icon */} ]}>
<View style={styles.iconContainer}> <View style={styles.notificationContent}>
<Ionicons {/* Icon */}
name={getNotificationIcon(item.data.msgType)} <View style={styles.iconContainer}>
size={24} <Ionicons
color={getNotificationColor(item.data.msgType)} name={getNotificationIcon(item.data.msgType)}
/> size={24}
</View> color={getNotificationColor(item.data.msgType)}
/>
{/* Content */}
<View style={styles.textContent}>
<View style={styles.headerRow}>
<Text style={[
styles.title,
!item.read && styles.unreadTitle
]}>
{item.data.title}
</Text>
<Text style={styles.time}>
{formatTime(item.sentTime)}
</Text>
</View> </View>
<Text style={styles.message}> {/* Content */}
{item.data.body} <View style={styles.textContent}>
</Text> <View style={styles.headerRow}>
{item.data.msgType && (
<View style={styles.tagContainer}>
<Text style={[ <Text style={[
styles.tag, styles.title,
{ backgroundColor: getNotificationColor(item.data.msgType) } !item.read && styles.unreadTitle
]}> ]}>
{/* {item.data.msgType} */} {item.data.title}
{getFilterDisplayName(item.data.msgType as FilterType)} </Text>
<Text style={styles.time}>
{formatTime(item.sentTime)}
</Text> </Text>
</View> </View>
)}
</View>
{/* Actions */} <Text style={styles.message}>
<View style={styles.actionsContainer}> {item.data.body}
{!item.read && ( </Text>
<View style={styles.unreadIndicator} />
)} {item.data.msgType && (
<TouchableOpacity <View style={styles.tagContainer}>
onPress={() => handleDelete(item.messageId)} <Text style={[
style={styles.deleteButton} styles.tag,
> { backgroundColor: getNotificationColor(item.data.msgType) }
<Ionicons name="trash-outline" size={20} color="#e63946" /> ]}>
</TouchableOpacity> {/* {item.data.msgType} */}
{getFilterDisplayName(item.data.msgType as FilterType)}
</Text>
</View>
)}
</View>
{/* Actions */}
<View style={styles.actionsContainer}>
{!item.read && (
<View style={styles.unreadIndicator} />
)}
<TouchableOpacity
onPress={() => handleDelete(item.messageId)}
style={styles.deleteButton}
>
<Ionicons name="trash-outline" size={20} color="#e63946" />
</TouchableOpacity>
</View>
</View> </View>
</View> </LinearGradient>
</LinearGradient> </TouchableOpacity>
</TouchableOpacity> )
)} }}
ListEmptyComponent={ ListEmptyComponent={
<View style={styles.emptyContainer}> <View style={styles.emptyContainer}>
<Ionicons name="notifications-off-outline" size={64} color="#ccc" /> <Ionicons name="notifications-off-outline" size={64} color="#ccc" />
+8 -13
View File
@@ -161,13 +161,13 @@ const Profile = () => {
// Alert.alert("Success", "Profile updated successfully"); // Alert.alert("Success", "Profile updated successfully");
// setEditing(false); // setEditing(false);
// fetchUserProfile(); // fetchUserProfile();
// if (result.status === "success") { if (result.status === "success") {
// Alert.alert("Success", "Profile updated successfully"); Alert.alert("Success", "Profile updated successfully");
// setEditing(false); setEditing(false);
// fetchUserProfile(); // reload updated data fetchUserProfile(); // reload updated data
// } else { } else {
// Alert.alert("Error", "Failed to update profile"); Alert.alert("Error", "Failed to update profile");
// } }
} catch (error) { } catch (error) {
console.error("❌ Error updating profile:", error); console.error("❌ Error updating profile:", error);
// Alert.alert("Error", "Could not update profile"); // Alert.alert("Error", "Could not update profile");
@@ -309,7 +309,7 @@ const Profile = () => {
return; return;
} }
await deleteFcmToken(); await deleteFcmToken(user?.userId?.toString());
// Clear stored credentials // Clear stored credentials
await Keychain.resetGenericPassword(); await Keychain.resetGenericPassword();
@@ -463,11 +463,6 @@ const Profile = () => {
<View> <View>
<Text style={styles.sectionTitle}>Personal Information</Text> <Text style={styles.sectionTitle}>Personal Information</Text>
<Text style={{ color: "#64748b", marginBottom: 16 }}>Become Organizer</Text> <Text style={{ color: "#64748b", marginBottom: 16 }}>Become Organizer</Text>
{/* <View style={{ marginBottom: 16 }}>
</View> */}
</View> </View>
<View> <View>
<TouchableOpacity onPress={() => navigation.navigate('Transaction')}> <TouchableOpacity onPress={() => navigation.navigate('Transaction')}>
+1
View File
@@ -239,6 +239,7 @@ const processAndAddNotification = (remoteMessage: any) => {
title: title, title: title,
additionalProp1: data?.additionalProp1 || '', additionalProp1: data?.additionalProp1 || '',
additionalProp2: data?.additionalProp2 || '', additionalProp2: data?.additionalProp2 || '',
groupId: data?.groupId || '',
...data // Spread any additional data ...data // Spread any additional data
}, },
from: from || 'unknown', from: from || 'unknown',