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