correct issues
This commit is contained in:
@@ -190,7 +190,8 @@ export default function GroupScreen() {
|
|||||||
try {
|
try {
|
||||||
const credentials = await Keychain.getGenericPassword();
|
const credentials = await Keychain.getGenericPassword();
|
||||||
if (!credentials) {
|
if (!credentials) {
|
||||||
Alert.alert("Error", "You are not logged in");
|
ToastAndroid.show('You are not logged in', ToastAndroid.SHORT);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const token = credentials.password;
|
const token = credentials.password;
|
||||||
@@ -233,7 +234,7 @@ export default function GroupScreen() {
|
|||||||
|
|
||||||
const handleViewGroup = (group: Group) => {
|
const handleViewGroup = (group: Group) => {
|
||||||
// navigation.navigate('GroupDetails', { group });
|
// navigation.navigate('GroupDetails', { group });
|
||||||
Alert.alert("View Group", `Viewing details for ${group.groupName}`);
|
ToastAndroid.show(`Viewing details for ${group.groupName}`, ToastAndroid.SHORT);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onRefresh = () => {
|
const onRefresh = () => {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
Alert,
|
Alert,
|
||||||
ActivityIndicator,
|
ActivityIndicator,
|
||||||
|
ToastAndroid,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import { RootStackParamList } from '../navigation/AppNavigator'; // Adjust path
|
import { RootStackParamList } from '../navigation/AppNavigator'; // Adjust path
|
||||||
import { apiCall } from '../utils/ApiHelper'; // Adjust path
|
import { apiCall } from '../utils/ApiHelper'; // Adjust path
|
||||||
@@ -78,9 +79,10 @@ const InviteScreen: FC<InviteScreenProps> = ({ route }) => {
|
|||||||
// Replace with your actual API call to join the group
|
// Replace with your actual API call to join the group
|
||||||
// For now, it just shows an alert.
|
// For now, it just shows an alert.
|
||||||
await apiCall(`http://192.168.1.5:9060/api/fund/groups/join/invite/${code}`, 'POST');
|
await apiCall(`http://192.168.1.5:9060/api/fund/groups/join/invite/${code}`, 'POST');
|
||||||
Alert.alert('Success!', `You have requested to join "${groupDetails.groupName}".`);
|
ToastAndroid.show(`You have requested to join "${groupDetails.groupName}".`, ToastAndroid.SHORT);
|
||||||
|
fetchGroupDetails(); // Refresh details after joining
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
Alert.alert('Join Error', e.message || 'An unexpected error occurred.');
|
ToastAndroid.show(e.message || 'An unexpected error occurred.', ToastAndroid.SHORT);
|
||||||
} finally {
|
} finally {
|
||||||
setJoining(false);
|
setJoining(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
KeyboardAvoidingView,
|
KeyboardAvoidingView,
|
||||||
Platform,
|
Platform,
|
||||||
ScrollView,
|
ScrollView,
|
||||||
|
ToastAndroid,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { ORGRAGISTRATION } from "../utils/ApiUrls";
|
import { ORGRAGISTRATION } from "../utils/ApiUrls";
|
||||||
@@ -30,7 +31,7 @@ export default function OrganizerRegisterScreen() {
|
|||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!bankAccountNumber || !bankName || !branchCode) {
|
if (!bankAccountNumber || !bankName || !branchCode) {
|
||||||
Alert.alert("Error", "All fields are required.");
|
ToastAndroid.show('All fields are required.', ToastAndroid.SHORT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +43,7 @@ const handleSubmit = async () => {
|
|||||||
const token = creds ? creds.password : null;
|
const token = creds ? creds.password : null;
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
Alert.alert("Error", "No token found. Please log in again.");
|
ToastAndroid.show('No token found. Please log in again.', ToastAndroid.SHORT);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -65,10 +66,13 @@ const handleSubmit = async () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
console.log("✅ Organizer Registered:", res.data);
|
console.log("✅ Organizer Registered:", res.data);
|
||||||
Alert.alert("Success", "Organizer registered successfully!");
|
ToastAndroid.show('Organizer registered successfully!', ToastAndroid.SHORT);
|
||||||
|
// Optionally, reset form fields
|
||||||
|
setBankAccountNumber("");
|
||||||
|
setBankName("");
|
||||||
|
setBranchCode("");
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
console.error("❌ Register Error:", err?.response?.data || err.message);
|
console.error("❌ Register Error:", err?.response?.data || err.message);
|
||||||
// Alert.alert("Error", "Failed to register. Please try again.");
|
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ const GroupList = () => {
|
|||||||
const fetchGroups = async () => {
|
const fetchGroups = async () => {
|
||||||
const credentials = await keychain.getGenericPassword();
|
const credentials = await keychain.getGenericPassword();
|
||||||
if (!credentials) {
|
if (!credentials) {
|
||||||
Alert.alert("Error", "You are not logged in");
|
ToastAndroid.show('You are not logged in', ToastAndroid.SHORT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const token = credentials.password;
|
const token = credentials.password;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
Alert,
|
Alert,
|
||||||
FlatList,
|
FlatList,
|
||||||
ListRenderItem,
|
ListRenderItem,
|
||||||
|
ToastAndroid,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
import AppView from "../../components/AppView";
|
import AppView from "../../components/AppView";
|
||||||
import colors from "../../components/colors";
|
import colors from "../../components/colors";
|
||||||
@@ -97,7 +98,7 @@ const Home: React.FC = () => {
|
|||||||
} else if (item.action === "NAVIGATE_CREATE_GROUP") {
|
} else if (item.action === "NAVIGATE_CREATE_GROUP") {
|
||||||
navigation.navigate("GroupCreation" as never);
|
navigation.navigate("GroupCreation" as never);
|
||||||
} else {
|
} else {
|
||||||
Alert.alert("Unknown action", item.title);
|
ToastAndroid.show(`Unknown action: ${item.title}`, ToastAndroid.SHORT);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ import {
|
|||||||
RefreshControl,
|
RefreshControl,
|
||||||
Alert,
|
Alert,
|
||||||
ActivityIndicator,
|
ActivityIndicator,
|
||||||
TextInput
|
TextInput,
|
||||||
|
ToastAndroid
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import { Ionicons } from '@react-native-vector-icons/ionicons';
|
import { Ionicons } from '@react-native-vector-icons/ionicons';
|
||||||
import colors from '../../components/colors';
|
import colors from '../../components/colors';
|
||||||
@@ -50,7 +51,7 @@ const RequestList: React.FC = () => {
|
|||||||
|
|
||||||
const credentials = await keychain.getGenericPassword();
|
const credentials = await keychain.getGenericPassword();
|
||||||
if (!credentials) {
|
if (!credentials) {
|
||||||
Alert.alert("Error", "You are not logged in");
|
ToastAndroid.show('You are not logged in', ToastAndroid.SHORT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const token = credentials.password;
|
const token = credentials.password;
|
||||||
@@ -146,14 +147,13 @@ const RequestList: React.FC = () => {
|
|||||||
// Remove the accepted request from the list
|
// Remove the accepted request from the list
|
||||||
const updatedRequests = requests.filter(req => req.requestId !== requestId);
|
const updatedRequests = requests.filter(req => req.requestId !== requestId);
|
||||||
setRequests(updatedRequests);
|
setRequests(updatedRequests);
|
||||||
Alert.alert("Success", data.message || "Request accepted successfully");
|
ToastAndroid.show(data.message || "Request accepted successfully", ToastAndroid.SHORT);
|
||||||
fetchRequests();
|
fetchRequests();
|
||||||
} else {
|
} else {
|
||||||
throw new Error(data.message || "Failed to accept request");
|
throw new Error(data.message || "Failed to accept request");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorMessage = error instanceof Error ? error.message : "An unknown error occurred";
|
const errorMessage = error instanceof Error ? error.message : "An unknown error occurred";
|
||||||
// Alert.alert("Error", `Failed to accept request: ${errorMessage}`);
|
|
||||||
console.error("Accept Error:", error);
|
console.error("Accept Error:", error);
|
||||||
} finally {
|
} finally {
|
||||||
setProcessingRequest(null);
|
setProcessingRequest(null);
|
||||||
@@ -192,14 +192,15 @@ const RequestList: React.FC = () => {
|
|||||||
// Remove the declined request from the list
|
// Remove the declined request from the list
|
||||||
const updatedRequests = requests.filter(req => req.requestId !== selectedRequestId);
|
const updatedRequests = requests.filter(req => req.requestId !== selectedRequestId);
|
||||||
setRequests(updatedRequests);
|
setRequests(updatedRequests);
|
||||||
Alert.alert("Success", data.message || "Request declined successfully");
|
ToastAndroid.show(data.message || "Request declined successfully", ToastAndroid.SHORT);
|
||||||
|
|
||||||
fetchRequests();
|
fetchRequests();
|
||||||
} else {
|
} else {
|
||||||
throw new Error(data.message || "Failed to decline request");
|
throw new Error(data.message || "Failed to decline request");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorMessage = error instanceof Error ? error.message : "An unknown error occurred";
|
const errorMessage = error instanceof Error ? error.message : "An unknown error occurred";
|
||||||
// Alert.alert("Error", `Failed to decline request: ${errorMessage}`);
|
|
||||||
console.error("Decline Error:", error);
|
console.error("Decline Error:", error);
|
||||||
} finally {
|
} finally {
|
||||||
setProcessingRequest(null);
|
setProcessingRequest(null);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ const UserProfileStatus: React.FC = () => {
|
|||||||
try {
|
try {
|
||||||
const credentials = await Keychain.getGenericPassword();
|
const credentials = await Keychain.getGenericPassword();
|
||||||
if (!credentials) {
|
if (!credentials) {
|
||||||
Alert.alert("Error", "You are not logged in");
|
ToastAndroid.show('You are not logged in', ToastAndroid.SHORT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const token = credentials.password;
|
const token = credentials.password;
|
||||||
|
|||||||
@@ -1,249 +1,267 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
// import React, { useEffect, useState } from "react";
|
||||||
import {
|
// import {
|
||||||
StyleSheet,
|
// StyleSheet,
|
||||||
Text,
|
// Text,
|
||||||
View,
|
// View,
|
||||||
FlatList,
|
// FlatList,
|
||||||
TouchableOpacity,
|
// TouchableOpacity,
|
||||||
Alert,
|
// Alert,
|
||||||
RefreshControl,
|
// RefreshControl,
|
||||||
ScrollView,
|
// ScrollView,
|
||||||
Button,
|
// Button,
|
||||||
} from "react-native";
|
// ToastAndroid,
|
||||||
import { useNavigation } from "@react-navigation/native";
|
// } from "react-native";
|
||||||
import type { NativeStackNavigationProp } from "@react-navigation/native-stack";
|
// import { useNavigation } from "@react-navigation/native";
|
||||||
import type { RootStackParamList } from "../../../navigation/AppNavigator";
|
// import type { NativeStackNavigationProp } from "@react-navigation/native-stack";
|
||||||
import colors from "../../../components/colors";
|
// import type { RootStackParamList } from "../../../navigation/AppNavigator";
|
||||||
import { Ionicons } from "@react-native-vector-icons/ionicons";
|
// import colors from "../../../components/colors";
|
||||||
import { GET_JOINED_GROUP_URL } from "../../../utils/ApiUrls";
|
// import { Ionicons } from "@react-native-vector-icons/ionicons";
|
||||||
import * as Keychain from "react-native-keychain";
|
// import { GET_JOINED_GROUP_URL } from "../../../utils/ApiUrls";
|
||||||
import AnimatedCard from "../../../components/common/AnimatedCard";
|
// import * as Keychain from "react-native-keychain";
|
||||||
|
// import AnimatedCard from "../../../components/common/AnimatedCard";
|
||||||
|
|
||||||
type NavigationProp = NativeStackNavigationProp<
|
// type NavigationProp = NativeStackNavigationProp<
|
||||||
RootStackParamList,
|
// RootStackParamList,
|
||||||
"GroupDetails"
|
// "GroupDetails"
|
||||||
>;
|
// >;
|
||||||
|
|
||||||
type Group = {
|
// type Group = {
|
||||||
id: string;
|
// id: string;
|
||||||
groupName: string;
|
// groupName: string;
|
||||||
description: string;
|
// description: string;
|
||||||
currentParticipants: number;
|
// currentParticipants: number;
|
||||||
maxParticipants: number;
|
// maxParticipants: number;
|
||||||
contributionAmount: number;
|
// contributionAmount: number;
|
||||||
status: string;
|
// status: string;
|
||||||
};
|
// };
|
||||||
|
|
||||||
|
// const UserHome = () => {
|
||||||
|
// const navigation = useNavigation<NavigationProp>();
|
||||||
|
// const [groups, setGroups] = useState<Group[]>([]);
|
||||||
|
// const [loading, setLoading] = useState<boolean>(false)
|
||||||
|
// const [refreshing, setRefreshing] = useState<boolean>(false)
|
||||||
|
|
||||||
|
|
||||||
|
// const activeGroups = groups.filter((g) => g.status === "ACTIVE");
|
||||||
|
|
||||||
|
// const totalGroups = activeGroups.length;
|
||||||
|
|
||||||
|
// const totalContribution = activeGroups.reduce(
|
||||||
|
// (sum, g) => sum + g.contributionAmount,
|
||||||
|
// 0
|
||||||
|
// );
|
||||||
|
|
||||||
|
// const onRefresh = async () => {
|
||||||
|
// setRefreshing(true)
|
||||||
|
// await handleGroup()
|
||||||
|
// setRefreshing(false)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// const handleGroup = async () => {
|
||||||
|
// try {
|
||||||
|
// setLoading(true)
|
||||||
|
// const credentials = await Keychain.getGenericPassword();
|
||||||
|
// if (!credentials) {
|
||||||
|
// ToastAndroid.show('You are not logged in', ToastAndroid.SHORT);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// const token = credentials.password;
|
||||||
|
|
||||||
|
// const response = await fetch(GET_JOINED_GROUP_URL, {
|
||||||
|
// method: "GET",
|
||||||
|
// headers: {
|
||||||
|
// Accept: "*/*",
|
||||||
|
// Authorization: `Bearer ${token}`,
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
|
||||||
|
// const result = await response.json();
|
||||||
|
// if (result.status === "success") {
|
||||||
|
// console.log("GET_JOINED_GROUP_URL res : ", result);
|
||||||
|
// setGroups(result.data); // save API data
|
||||||
|
// setLoading(false)
|
||||||
|
// } else {
|
||||||
|
// ToastAndroid.show("Failed to fetch groups", ToastAndroid.SHORT);
|
||||||
|
// setLoading(false)
|
||||||
|
// }
|
||||||
|
// } catch (error) {
|
||||||
|
// console.error("❌ Error fetching groups:", error);
|
||||||
|
// } finally {
|
||||||
|
// setLoading(false)
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
|
// useEffect(() => {
|
||||||
|
// handleGroup();
|
||||||
|
// }, []);
|
||||||
|
|
||||||
|
// const renderItem = ({ item }: { item: Group }) => {
|
||||||
|
// return (
|
||||||
|
// <TouchableOpacity
|
||||||
|
// style={styles.card}
|
||||||
|
// onPress={() => navigation.navigate("GroupDetails", { item })}
|
||||||
|
// >
|
||||||
|
// <Text style={styles.groupName}>{item.groupName}</Text>
|
||||||
|
// <Text style={styles.description} numberOfLines={1}>{item.description}</Text>
|
||||||
|
// <View style={styles.statsRow}>
|
||||||
|
// <Ionicons
|
||||||
|
// name="person-circle-outline"
|
||||||
|
// size={20}
|
||||||
|
// color={colors.primary}
|
||||||
|
// />
|
||||||
|
// <Text style={styles.detail}>
|
||||||
|
// {item.currentParticipants}/{item.maxParticipants} members
|
||||||
|
// </Text>
|
||||||
|
// </View>
|
||||||
|
|
||||||
|
// <Text style={styles.amount}>
|
||||||
|
// Contribution: ₹{item.contributionAmount}
|
||||||
|
// </Text>
|
||||||
|
// <Text style={styles.status}>Status: {item.status}</Text>
|
||||||
|
// </TouchableOpacity>
|
||||||
|
// );
|
||||||
|
// };
|
||||||
|
|
||||||
|
// return (
|
||||||
|
// <ScrollView>
|
||||||
|
// {/* Stats */}
|
||||||
|
|
||||||
|
// {/* <Button title="Transaction List" onPress={()=>navigation.navigate('TransactionList')}/> */}
|
||||||
|
// <AnimatedCard
|
||||||
|
// onPress={() => navigation.navigate("TransactionList")}
|
||||||
|
// title={"transaction list"} iconName="calculator-outline"
|
||||||
|
// subtitle="View your transaction history"
|
||||||
|
// backOne={colors.Home}
|
||||||
|
// backTwo={colors.pastelPink}
|
||||||
|
// />
|
||||||
|
// <AnimatedCard
|
||||||
|
// onPress={() => navigation.navigate("Management" as never)}
|
||||||
|
// title={"Group Management"}
|
||||||
|
// iconName="person-outline"
|
||||||
|
// subtitle="Manage your joined & requested groups"
|
||||||
|
// backOne={colors.Settings}
|
||||||
|
// backTwo={colors.pastelOrange}
|
||||||
|
// />
|
||||||
|
|
||||||
|
// <View style={[styles.statsRow, { marginTop: 12 }]}>
|
||||||
|
// <View style={styles.statBox}>
|
||||||
|
// <Text style={styles.statValue}>{totalGroups}</Text>
|
||||||
|
// <Text style={styles.statLabel}>Groups Joined</Text>
|
||||||
|
// </View>
|
||||||
|
// <View style={styles.statBox}>
|
||||||
|
// <Text style={styles.statValue}>₹{totalContribution}</Text>
|
||||||
|
// <Text style={styles.statLabel}>Cycle Contribution</Text>
|
||||||
|
// </View>
|
||||||
|
// </View>
|
||||||
|
|
||||||
|
|
||||||
|
// {/* Groups List */}
|
||||||
|
// <Text style={styles.sectionTitle}>Your Groups</Text>
|
||||||
|
// <FlatList
|
||||||
|
// data={groups.filter((status) => status.status === "ACTIVE")}
|
||||||
|
// keyExtractor={(item) => item.id}
|
||||||
|
// renderItem={renderItem}
|
||||||
|
// contentContainerStyle={{ paddingBottom: 20 }}
|
||||||
|
// onRefresh={onRefresh}
|
||||||
|
// refreshing={refreshing}
|
||||||
|
// />
|
||||||
|
// </ScrollView>
|
||||||
|
// );
|
||||||
|
// };
|
||||||
|
|
||||||
|
// export default UserHome;
|
||||||
|
|
||||||
|
// const styles = StyleSheet.create({
|
||||||
|
// statsRow: {
|
||||||
|
// flexDirection: "row",
|
||||||
|
// gap: 10,
|
||||||
|
// },
|
||||||
|
// statBox: {
|
||||||
|
// flex: 1,
|
||||||
|
// backgroundColor: "#fff",
|
||||||
|
// padding: 16,
|
||||||
|
// borderRadius: 12,
|
||||||
|
// alignItems: "center",
|
||||||
|
// shadowColor: "#000",
|
||||||
|
// shadowOpacity: 0.05,
|
||||||
|
// shadowOffset: { width: 0, height: 2 },
|
||||||
|
// shadowRadius: 6,
|
||||||
|
// elevation: 2,
|
||||||
|
// borderWidth:1,
|
||||||
|
// borderColor:colors.Home
|
||||||
|
// },
|
||||||
|
// statValue: {
|
||||||
|
// fontSize: 18,
|
||||||
|
// fontWeight: "700",
|
||||||
|
// color: colors.Home,
|
||||||
|
// },
|
||||||
|
// statLabel: {
|
||||||
|
// fontSize: 12,
|
||||||
|
// color: "#64748b",
|
||||||
|
// marginTop: 4,
|
||||||
|
// },
|
||||||
|
// sectionTitle: {
|
||||||
|
// fontSize: 18,
|
||||||
|
// fontWeight: "600",
|
||||||
|
// color: colors.Home,
|
||||||
|
// marginBottom: 12,
|
||||||
|
// marginTop:15
|
||||||
|
// },
|
||||||
|
// card: {
|
||||||
|
// backgroundColor: "#ffffff",
|
||||||
|
// padding: 16,
|
||||||
|
// marginBottom: 12,
|
||||||
|
// borderRadius: 12,
|
||||||
|
// shadowColor: "#000",
|
||||||
|
// shadowOpacity: 0.05,
|
||||||
|
// shadowOffset: { width: 0, height: 2 },
|
||||||
|
// shadowRadius: 6,
|
||||||
|
// elevation: 2,
|
||||||
|
// borderLeftWidth: 5,
|
||||||
|
// borderColor: colors.Home
|
||||||
|
// },
|
||||||
|
// groupName: {
|
||||||
|
// fontSize: 16,
|
||||||
|
// fontWeight: "600",
|
||||||
|
// color: colors.Home,
|
||||||
|
// marginBottom: 4,
|
||||||
|
// },
|
||||||
|
// description: {
|
||||||
|
// fontSize: 13,
|
||||||
|
// color: "#475569",
|
||||||
|
// marginBottom: 8,
|
||||||
|
// },
|
||||||
|
// detail: {
|
||||||
|
// fontSize: 13,
|
||||||
|
// color: "#475569",
|
||||||
|
// marginBottom: 8,
|
||||||
|
// },
|
||||||
|
// amount: {
|
||||||
|
// fontSize: 13,
|
||||||
|
// color: "#64748b",
|
||||||
|
// marginTop: 4,
|
||||||
|
// },
|
||||||
|
// status: {
|
||||||
|
// fontSize: 12,
|
||||||
|
// fontWeight: "500",
|
||||||
|
// color: colors.primary,
|
||||||
|
// marginTop: 2,
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import { StyleSheet, Text, View } from 'react-native'
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
const UserHome = () => {
|
const UserHome = () => {
|
||||||
const navigation = useNavigation<NavigationProp>();
|
return (
|
||||||
const [groups, setGroups] = useState<Group[]>([]);
|
<View>
|
||||||
const [loading, setLoading] = useState<boolean>(false)
|
<Text>UserHome</Text>
|
||||||
const [refreshing, setRefreshing] = useState<boolean>(false)
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default UserHome
|
||||||
|
|
||||||
const activeGroups = groups.filter((g) => g.status === "ACTIVE");
|
const styles = StyleSheet.create({})
|
||||||
|
|
||||||
const totalGroups = activeGroups.length;
|
|
||||||
|
|
||||||
const totalContribution = activeGroups.reduce(
|
|
||||||
(sum, g) => sum + g.contributionAmount,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
|
|
||||||
const onRefresh = async () => {
|
|
||||||
setRefreshing(true)
|
|
||||||
await handleGroup()
|
|
||||||
setRefreshing(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleGroup = async () => {
|
|
||||||
try {
|
|
||||||
setLoading(true)
|
|
||||||
const credentials = await Keychain.getGenericPassword();
|
|
||||||
if (!credentials) {
|
|
||||||
Alert.alert("Error", "You are not logged in");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const token = credentials.password;
|
|
||||||
|
|
||||||
const response = await fetch(GET_JOINED_GROUP_URL, {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
Accept: "*/*",
|
|
||||||
Authorization: `Bearer ${token}`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = await response.json();
|
|
||||||
if (result.status === "success") {
|
|
||||||
console.log("GET_JOINED_GROUP_URL res : ", result);
|
|
||||||
setGroups(result.data); // save API data
|
|
||||||
setLoading(false)
|
|
||||||
} else {
|
|
||||||
Alert.alert("Error", "Failed to fetch groups");
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("❌ Error fetching groups:", error);
|
|
||||||
// Alert.alert("Error", "Could not connect to server");
|
|
||||||
} finally {
|
|
||||||
setLoading(false)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
handleGroup();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const renderItem = ({ item }: { item: Group }) => {
|
|
||||||
return (
|
|
||||||
<TouchableOpacity
|
|
||||||
style={styles.card}
|
|
||||||
onPress={() => navigation.navigate("GroupDetails", { item })}
|
|
||||||
>
|
|
||||||
<Text style={styles.groupName}>{item.groupName}</Text>
|
|
||||||
<Text style={styles.description} numberOfLines={1}>{item.description}</Text>
|
|
||||||
<View style={styles.statsRow}>
|
|
||||||
<Ionicons
|
|
||||||
name="person-circle-outline"
|
|
||||||
size={20}
|
|
||||||
color={colors.primary}
|
|
||||||
/>
|
|
||||||
<Text style={styles.detail}>
|
|
||||||
{item.currentParticipants}/{item.maxParticipants} members
|
|
||||||
</Text>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
<Text style={styles.amount}>
|
|
||||||
Contribution: ₹{item.contributionAmount}
|
|
||||||
</Text>
|
|
||||||
<Text style={styles.status}>Status: {item.status}</Text>
|
|
||||||
</TouchableOpacity>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ScrollView>
|
|
||||||
{/* Stats */}
|
|
||||||
|
|
||||||
{/* <Button title="Transaction List" onPress={()=>navigation.navigate('TransactionList')}/> */}
|
|
||||||
<AnimatedCard
|
|
||||||
onPress={() => navigation.navigate("TransactionList")}
|
|
||||||
title={"transaction list"} iconName="calculator-outline"
|
|
||||||
subtitle="View your transaction history"
|
|
||||||
backOne={colors.Home}
|
|
||||||
backTwo={colors.pastelPink}
|
|
||||||
/>
|
|
||||||
<AnimatedCard
|
|
||||||
onPress={() => navigation.navigate("Management" as never)}
|
|
||||||
title={"Group Management"}
|
|
||||||
iconName="person-outline"
|
|
||||||
subtitle="Manage your joined & requested groups"
|
|
||||||
backOne={colors.Settings}
|
|
||||||
backTwo={colors.pastelOrange}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<View style={[styles.statsRow, { marginTop: 12 }]}>
|
|
||||||
<View style={styles.statBox}>
|
|
||||||
<Text style={styles.statValue}>{totalGroups}</Text>
|
|
||||||
<Text style={styles.statLabel}>Groups Joined</Text>
|
|
||||||
</View>
|
|
||||||
<View style={styles.statBox}>
|
|
||||||
<Text style={styles.statValue}>₹{totalContribution}</Text>
|
|
||||||
<Text style={styles.statLabel}>Cycle Contribution</Text>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
|
|
||||||
{/* Groups List */}
|
|
||||||
<Text style={styles.sectionTitle}>Your Groups</Text>
|
|
||||||
<FlatList
|
|
||||||
data={groups.filter((status) => status.status === "ACTIVE")}
|
|
||||||
keyExtractor={(item) => item.id}
|
|
||||||
renderItem={renderItem}
|
|
||||||
contentContainerStyle={{ paddingBottom: 20 }}
|
|
||||||
onRefresh={onRefresh}
|
|
||||||
refreshing={refreshing}
|
|
||||||
/>
|
|
||||||
</ScrollView>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default UserHome;
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
|
||||||
statsRow: {
|
|
||||||
flexDirection: "row",
|
|
||||||
gap: 10,
|
|
||||||
},
|
|
||||||
statBox: {
|
|
||||||
flex: 1,
|
|
||||||
backgroundColor: "#fff",
|
|
||||||
padding: 16,
|
|
||||||
borderRadius: 12,
|
|
||||||
alignItems: "center",
|
|
||||||
shadowColor: "#000",
|
|
||||||
shadowOpacity: 0.05,
|
|
||||||
shadowOffset: { width: 0, height: 2 },
|
|
||||||
shadowRadius: 6,
|
|
||||||
elevation: 2,
|
|
||||||
borderWidth:1,
|
|
||||||
borderColor:colors.Home
|
|
||||||
},
|
|
||||||
statValue: {
|
|
||||||
fontSize: 18,
|
|
||||||
fontWeight: "700",
|
|
||||||
color: colors.Home,
|
|
||||||
},
|
|
||||||
statLabel: {
|
|
||||||
fontSize: 12,
|
|
||||||
color: "#64748b",
|
|
||||||
marginTop: 4,
|
|
||||||
},
|
|
||||||
sectionTitle: {
|
|
||||||
fontSize: 18,
|
|
||||||
fontWeight: "600",
|
|
||||||
color: colors.Home,
|
|
||||||
marginBottom: 12,
|
|
||||||
marginTop:15
|
|
||||||
},
|
|
||||||
card: {
|
|
||||||
backgroundColor: "#ffffff",
|
|
||||||
padding: 16,
|
|
||||||
marginBottom: 12,
|
|
||||||
borderRadius: 12,
|
|
||||||
shadowColor: "#000",
|
|
||||||
shadowOpacity: 0.05,
|
|
||||||
shadowOffset: { width: 0, height: 2 },
|
|
||||||
shadowRadius: 6,
|
|
||||||
elevation: 2,
|
|
||||||
borderLeftWidth: 5,
|
|
||||||
borderColor: colors.Home
|
|
||||||
},
|
|
||||||
groupName: {
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: "600",
|
|
||||||
color: colors.Home,
|
|
||||||
marginBottom: 4,
|
|
||||||
},
|
|
||||||
description: {
|
|
||||||
fontSize: 13,
|
|
||||||
color: "#475569",
|
|
||||||
marginBottom: 8,
|
|
||||||
},
|
|
||||||
detail: {
|
|
||||||
fontSize: 13,
|
|
||||||
color: "#475569",
|
|
||||||
marginBottom: 8,
|
|
||||||
},
|
|
||||||
amount: {
|
|
||||||
fontSize: 13,
|
|
||||||
color: "#64748b",
|
|
||||||
marginTop: 4,
|
|
||||||
},
|
|
||||||
status: {
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: "500",
|
|
||||||
color: colors.primary,
|
|
||||||
marginTop: 2,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -202,18 +202,18 @@ const EditGroupScreen: React.FC<EditGroupScreenProps> = ({ route }) => {
|
|||||||
|
|
||||||
|
|
||||||
if (editableData.maxParticipants < groupDetails.totalParticipants) {
|
if (editableData.maxParticipants < groupDetails.totalParticipants) {
|
||||||
Alert.alert('Invalid Input', `Max participants cannot be less than the current count (${groupDetails.totalParticipants}).`);
|
ToastAndroid.show(`Max participants cannot be less than the current count (${groupDetails.totalParticipants}).`, ToastAndroid.SHORT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
try {
|
try {
|
||||||
await apiCall(`${BASE_URL}fund/groups/${groupDetails.id}/edit`, 'PUT', editableData);
|
await apiCall(`${BASE_URL}fund/groups/${groupDetails.id}/edit`, 'PUT', editableData);
|
||||||
Alert.alert('Success', 'Group has been updated.');
|
ToastAndroid.show('Group has been updated.', ToastAndroid.SHORT);
|
||||||
setEditingCard(null);
|
setEditingCard(null);
|
||||||
await fetchGroupDetails();
|
await fetchGroupDetails();
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
Alert.alert('Save Error', e.message || 'An unexpected error occurred.');
|
ToastAndroid.show(e.message || 'An unexpected error occurred.', ToastAndroid.SHORT);
|
||||||
} finally {
|
} finally {
|
||||||
setSaving(false);
|
setSaving(false);
|
||||||
}
|
}
|
||||||
@@ -241,11 +241,11 @@ const EditGroupScreen: React.FC<EditGroupScreenProps> = ({ route }) => {
|
|||||||
setStarting(true);
|
setStarting(true);
|
||||||
try {
|
try {
|
||||||
await apiCall(`${BASE_URL}fund/group/start?groupId=${groupDetails.id}`, 'GET');
|
await apiCall(`${BASE_URL}fund/group/start?groupId=${groupDetails.id}`, 'GET');
|
||||||
Alert.alert('Success', 'Group has been started successfully.');
|
ToastAndroid.show('Group has been started successfully.', ToastAndroid.SHORT);
|
||||||
await fetchGroupDetails();
|
await fetchGroupDetails();
|
||||||
navigation.goBack()
|
navigation.goBack()
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
Alert.alert('Start Error', e.message || 'An unexpected error occurred.');
|
ToastAndroid.show(e.message || 'An unexpected error occurred.', ToastAndroid.SHORT);
|
||||||
} finally {
|
} finally {
|
||||||
setStarting(false);
|
setStarting(false);
|
||||||
}
|
}
|
||||||
@@ -267,7 +267,7 @@ const EditGroupScreen: React.FC<EditGroupScreenProps> = ({ route }) => {
|
|||||||
|
|
||||||
if (inviteLink) {
|
if (inviteLink) {
|
||||||
Clipboard.setString(inviteLink);
|
Clipboard.setString(inviteLink);
|
||||||
Alert.alert('Copied!', 'Invitation link copied to clipboard.');
|
ToastAndroid.show('Invitation link copied to clipboard.', ToastAndroid.SHORT);
|
||||||
await Share.share({
|
await Share.share({
|
||||||
message: `Join my group on CircleCollect! ${inviteLink}`,
|
message: `Join my group on CircleCollect! ${inviteLink}`,
|
||||||
url: inviteLink,
|
url: inviteLink,
|
||||||
@@ -277,7 +277,7 @@ const EditGroupScreen: React.FC<EditGroupScreenProps> = ({ route }) => {
|
|||||||
throw new Error('Could not generate invitation link.');
|
throw new Error('Could not generate invitation link.');
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
Alert.alert('Error', error.message || 'Failed to generate invitation.');
|
ToastAndroid.show(error.message || 'Failed to generate invitation.', ToastAndroid.SHORT);
|
||||||
} finally {
|
} finally {
|
||||||
setInviting(false);
|
setInviting(false);
|
||||||
}
|
}
|
||||||
@@ -380,30 +380,18 @@ const EditGroupScreen: React.FC<EditGroupScreenProps> = ({ route }) => {
|
|||||||
const canStartGroup = groupDetails.status === 'APPROVED' && groupDetails.totalParticipants >= groupDetails.minParticipants;
|
const canStartGroup = groupDetails.status === 'APPROVED' && groupDetails.totalParticipants >= groupDetails.minParticipants;
|
||||||
|
|
||||||
console.log(" myu status : ", groupDetails.status)
|
console.log(" myu status : ", groupDetails.status)
|
||||||
// const pickImage = () => {
|
|
||||||
// launchImageLibrary({ mediaType: "photo", quality: 0.5 }, (response) => {
|
|
||||||
// if (response.didCancel) return;
|
|
||||||
// if (response.errorCode) {
|
|
||||||
// Alert.alert("Error", response.errorMessage || "Something went wrong");
|
|
||||||
// } else if (response.assets && response.assets.length > 0) {
|
|
||||||
// const selectedImage = response.assets[0];
|
|
||||||
// console.log(selectedImage?.uri)
|
|
||||||
// setSelectedImage(selectedImage?.uri)
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// };
|
|
||||||
|
|
||||||
const pickImage = () => {
|
const pickImage = () => {
|
||||||
launchImageLibrary({ mediaType: "photo", quality: 0.5 }, (response) => {
|
launchImageLibrary({ mediaType: "photo", quality: 0.5 }, (response) => {
|
||||||
if (response.didCancel) return;
|
if (response.didCancel) return;
|
||||||
|
|
||||||
if (response.errorCode) {
|
if (response.errorCode) {
|
||||||
Alert.alert("Error", response.errorMessage || "Something went wrong");
|
ToastAndroid.show(response.errorMessage || "Something went wrong", ToastAndroid.SHORT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!response.assets || response.assets.length === 0) {
|
if (!response.assets || response.assets.length === 0) {
|
||||||
Alert.alert("Error", "No image selected");
|
ToastAndroid.show("No image selected", ToastAndroid.SHORT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,7 +411,7 @@ const EditGroupScreen: React.FC<EditGroupScreenProps> = ({ route }) => {
|
|||||||
|
|
||||||
// Additional validation for required fields
|
// Additional validation for required fields
|
||||||
if (!selectedImage.uri) {
|
if (!selectedImage.uri) {
|
||||||
Alert.alert("Error", "Invalid image file");
|
ToastAndroid.show("Invalid image file", ToastAndroid.SHORT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -442,13 +430,13 @@ const EditGroupScreen: React.FC<EditGroupScreenProps> = ({ route }) => {
|
|||||||
try {
|
try {
|
||||||
const credentials = await Keychain.getGenericPassword();
|
const credentials = await Keychain.getGenericPassword();
|
||||||
if (!credentials) {
|
if (!credentials) {
|
||||||
Alert.alert("Error", "You are not logged in");
|
ToastAndroid.show('You are not logged in', ToastAndroid.SHORT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const token = credentials.password;
|
const token = credentials.password;
|
||||||
|
|
||||||
if (!selectedImage) {
|
if (!selectedImage) {
|
||||||
Alert.alert("Error", "Please select an image first");
|
ToastAndroid.show("Please select an image first", ToastAndroid.SHORT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -487,7 +475,6 @@ const EditGroupScreen: React.FC<EditGroupScreenProps> = ({ route }) => {
|
|||||||
|
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error("❌ Error updating group image:", error);
|
console.error("❌ Error updating group image:", error);
|
||||||
// Alert.alert("Error", error.message || "Could not update group image");
|
|
||||||
} finally {
|
} finally {
|
||||||
setImageUpdating(false);
|
setImageUpdating(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
ActivityIndicator,
|
ActivityIndicator,
|
||||||
Alert,
|
Alert,
|
||||||
|
ToastAndroid,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
import { useNavigation, useFocusEffect, useRoute, RouteProp } from "@react-navigation/native";
|
import { useNavigation, useFocusEffect, useRoute, RouteProp } from "@react-navigation/native";
|
||||||
import { StackNavigationProp } from "@react-navigation/stack";
|
import { StackNavigationProp } from "@react-navigation/stack";
|
||||||
@@ -102,13 +103,14 @@ const ManagementScreen: FC = () => {
|
|||||||
// No need to set loading here if the whole screen is already loading
|
// No need to set loading here if the whole screen is already loading
|
||||||
const res = await apiCall(url, "PUT", {}) as ApiResponse<null> | null;
|
const res = await apiCall(url, "PUT", {}) as ApiResponse<null> | null;
|
||||||
if (res && res.statusCode === 200) {
|
if (res && res.statusCode === 200) {
|
||||||
Alert.alert("Success", res.message || successMessage);
|
ToastAndroid.show("Success", ToastAndroid.SHORT);
|
||||||
fetchData(); // Refresh data after action
|
fetchData(); // Refresh data after action
|
||||||
} else {
|
} else {
|
||||||
throw new Error(res?.message || failureMessage);
|
throw new Error(res?.message || failureMessage);
|
||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
// Alert.alert("Error", err.message || "An unexpected error occurred.");
|
console.error("Action Error:", err);
|
||||||
|
ToastAndroid.show(err.message || failureMessage, ToastAndroid.SHORT);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { useEffect, useState, useCallback } from 'react';
|
import React, { useEffect, useState, useCallback } from 'react';
|
||||||
import { View, Text, StyleSheet, ActivityIndicator, ScrollView, RefreshControl, Alert, TouchableOpacity, Modal, TextInput } from 'react-native';
|
import { View, Text, StyleSheet, ActivityIndicator, ScrollView, RefreshControl, Alert, TouchableOpacity, Modal, TextInput, ToastAndroid } from 'react-native';
|
||||||
import { useRoute, RouteProp } from '@react-navigation/native';
|
import { useRoute, RouteProp } from '@react-navigation/native';
|
||||||
import { Ionicons } from "@react-native-vector-icons/ionicons";
|
import { Ionicons } from "@react-native-vector-icons/ionicons";
|
||||||
import colors from '../../components/colors';
|
import colors from '../../components/colors';
|
||||||
@@ -121,12 +121,12 @@ const Payments: React.FC = () => {
|
|||||||
const amountToWaive = parseFloat(waiverAmount);
|
const amountToWaive = parseFloat(waiverAmount);
|
||||||
|
|
||||||
if (isNaN(amountToWaive) || amountToWaive < 0) {
|
if (isNaN(amountToWaive) || amountToWaive < 0) {
|
||||||
Alert.alert("Invalid Input", "Please enter a valid waiver amount.");
|
ToastAndroid.show("Please enter a valid waiver amount.", ToastAndroid.SHORT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (amountToWaive > currentParticipant.lateFee) {
|
if (amountToWaive > currentParticipant.lateFee) {
|
||||||
Alert.alert("Invalid Amount", `Waiver cannot exceed the current late fee of ₹${currentParticipant.lateFee}.`);
|
ToastAndroid.show(`Waiver cannot exceed the current late fee of ₹${currentParticipant.lateFee}.`, ToastAndroid.SHORT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,14 +135,15 @@ const Payments: React.FC = () => {
|
|||||||
const response = await apiCall(url, 'PUT', {}) as any;
|
const response = await apiCall(url, 'PUT', {}) as any;
|
||||||
|
|
||||||
if (response && response.statusCode === 200) {
|
if (response && response.statusCode === 200) {
|
||||||
Alert.alert("Success", `₹${amountToWaive} has been waived successfully.`);
|
ToastAndroid.show(`₹${amountToWaive} has been waived successfully.`, ToastAndroid.SHORT);
|
||||||
setModalVisible(false);
|
setModalVisible(false);
|
||||||
onRefresh();
|
onRefresh();
|
||||||
} else {
|
} else {
|
||||||
throw new Error(response?.message || "Failed to apply waiver.");
|
throw new Error(response?.message || "Failed to apply waiver.");
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
Alert.alert("API Error", error.message);
|
ToastAndroid.show(error.message || "Failed to apply waiver.", ToastAndroid.SHORT);
|
||||||
|
console.error("Waive Fee Error:", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { useState, useEffect, useRef } from 'react';
|
import React, { useState, useEffect, useRef } from 'react';
|
||||||
import { View, Text, StyleSheet, TouchableOpacity, FlatList, Dimensions, Alert, ActivityIndicator, Animated, Button } from 'react-native';
|
import { View, Text, StyleSheet, TouchableOpacity, FlatList, Dimensions, Alert, ActivityIndicator, Animated, Button, ToastAndroid } from 'react-native';
|
||||||
import { apiCall } from '../../utils/ApiHelper';
|
import { apiCall } from '../../utils/ApiHelper';
|
||||||
import { Ionicons } from "@react-native-vector-icons/ionicons";
|
import { Ionicons } from "@react-native-vector-icons/ionicons";
|
||||||
import { useNavigation } from '@react-navigation/native';
|
import { useNavigation } from '@react-navigation/native';
|
||||||
@@ -44,10 +44,10 @@ const RandomSelectUserScreen: React.FC<{ route: any }> = ({ route }) => {
|
|||||||
|
|
||||||
setUsers(formattedUsers);
|
setUsers(formattedUsers);
|
||||||
} else {
|
} else {
|
||||||
Alert.alert('Error', 'Failed to fetch participants.');
|
ToastAndroid.show('Failed to fetch participants.', ToastAndroid.SHORT);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Alert.alert('Error', 'Could not connect to the server to fetch participants.');
|
ToastAndroid.show('Could not connect to the server to fetch participants.', ToastAndroid.SHORT);
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
@@ -94,7 +94,7 @@ const RandomSelectUserScreen: React.FC<{ route: any }> = ({ route }) => {
|
|||||||
const availableUsers = users.filter(u => !u.selected);
|
const availableUsers = users.filter(u => !u.selected);
|
||||||
|
|
||||||
if (availableUsers.length === 0 || isAnimating) {
|
if (availableUsers.length === 0 || isAnimating) {
|
||||||
Alert.alert('Info', 'All users are already selected.');
|
ToastAndroid.show('All users are already selected.', ToastAndroid.SHORT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,14 +134,14 @@ const RandomSelectUserScreen: React.FC<{ route: any }> = ({ route }) => {
|
|||||||
setWinner(winnerData);
|
setWinner(winnerData);
|
||||||
setHighlightedIndex(winnerIndex);
|
setHighlightedIndex(winnerIndex);
|
||||||
} else {
|
} else {
|
||||||
Alert.alert('Error', 'Winner not found among participants.');
|
ToastAndroid.show('Winner not found among participants.', ToastAndroid.SHORT);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Alert.alert('Error', 'Failed to determine a winner from the API.');
|
ToastAndroid.show('Failed to determine a winner from the API.', ToastAndroid.SHORT);
|
||||||
}
|
}
|
||||||
navigation.replace('EditGroup', { groupId })
|
navigation.replace('EditGroup', { groupId })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Alert.alert('Error', 'Could not connect to the server to fetch the winner.');
|
ToastAndroid.show('Could not connect to the server to fetch the winner.', ToastAndroid.SHORT);
|
||||||
} finally {
|
} finally {
|
||||||
setIsAnimating(false);
|
setIsAnimating(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
NativeModules,
|
NativeModules,
|
||||||
Linking,
|
Linking,
|
||||||
Alert,
|
Alert,
|
||||||
|
ToastAndroid,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
import AppView from "../../components/AppView";
|
import AppView from "../../components/AppView";
|
||||||
import colors from "../../components/colors";
|
import colors from "../../components/colors";
|
||||||
@@ -83,7 +84,7 @@ const YourContacts = () => {
|
|||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Error sending to WhatsApp:", err);
|
console.error("Error sending to WhatsApp:", err);
|
||||||
Alert.alert("Error", "Something went wrong while trying to open WhatsApp");
|
ToastAndroid.show("Something went wrong while trying to open WhatsApp", ToastAndroid.SHORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
setModalVisible(false);
|
setModalVisible(false);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
KeyboardAvoidingView,
|
KeyboardAvoidingView,
|
||||||
Platform,
|
Platform,
|
||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
|
ToastAndroid,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
import * as Keychain from "react-native-keychain";
|
import * as Keychain from "react-native-keychain";
|
||||||
import { CustomInput, CustomButton } from "../../components/common/Custom";
|
import { CustomInput, CustomButton } from "../../components/common/Custom";
|
||||||
@@ -27,7 +28,7 @@ const BecomeOrg = () => {
|
|||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!idName || !idNumber || !issueDate) {
|
if (!idName || !idNumber || !issueDate) {
|
||||||
Alert.alert("Error", "Please fill all fields");
|
ToastAndroid.show("Please fill all fields", ToastAndroid.SHORT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +36,7 @@ const BecomeOrg = () => {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
const credentials = await Keychain.getGenericPassword();
|
const credentials = await Keychain.getGenericPassword();
|
||||||
if (!credentials) {
|
if (!credentials) {
|
||||||
Alert.alert("Error", "You are not logged in. Please log in to continue.");
|
ToastAndroid.show("You are not logged in. Please log in to continue.", ToastAndroid.SHORT);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
// Optionally navigate to login screen
|
// Optionally navigate to login screen
|
||||||
// navigation.navigate("Login");
|
// navigation.navigate("Login");
|
||||||
@@ -62,17 +63,17 @@ const BecomeOrg = () => {
|
|||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
|
|
||||||
if (response.ok && result.status === "success") {
|
if (response.ok && result.status === "success") {
|
||||||
Alert.alert("Success", "Organizer registration application submitted successfully!");
|
ToastAndroid.show("Organizer registration application submitted successfully!", ToastAndroid.SHORT);
|
||||||
setIdName("");
|
setIdName("");
|
||||||
setIdNumber("");
|
setIdNumber("");
|
||||||
setIssueDate("");
|
setIssueDate("");
|
||||||
navigation.navigate("Home" as never);
|
navigation.navigate("Home" as never);
|
||||||
} else {
|
} else {
|
||||||
Alert.alert("Error", result.message || "Failed to submit application");
|
ToastAndroid.show(result.message || "Failed to submit application", ToastAndroid.SHORT);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("❌ Registration error:", error);
|
console.error("❌ Registration error:", error);
|
||||||
// Alert.alert("Error", "An unexpected error occurred. Please try again.");
|
ToastAndroid.show("An unexpected error occurred. Please try again.", ToastAndroid.SHORT);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
Alert,
|
Alert,
|
||||||
ActivityIndicator,
|
ActivityIndicator,
|
||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
|
ToastAndroid,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
import { useNavigation, useRoute } from "@react-navigation/native";
|
import { useNavigation, useRoute } from "@react-navigation/native";
|
||||||
import { CustomButton, CustomInput } from "../../components/common/Custom";
|
import { CustomButton, CustomInput } from "../../components/common/Custom";
|
||||||
@@ -39,7 +40,7 @@ const EditBankDetails = () => {
|
|||||||
// The update function remains the same, using the local state
|
// The update function remains the same, using the local state
|
||||||
const handleUpdateBankDetails = async () => {
|
const handleUpdateBankDetails = async () => {
|
||||||
if (!bankName || !bankAccountNumber || !branchCode) {
|
if (!bankName || !bankAccountNumber || !branchCode) {
|
||||||
Alert.alert("Validation Error", "Please fill in all bank details.");
|
ToastAndroid.show("Please fill in all bank details.", ToastAndroid.SHORT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,14 +53,14 @@ const EditBankDetails = () => {
|
|||||||
}) as { status: string; message?: string };
|
}) as { status: string; message?: string };
|
||||||
console.log("Update Bank Response:", response);
|
console.log("Update Bank Response:", response);
|
||||||
if (response.status === "success") {
|
if (response.status === "success") {
|
||||||
Alert.alert("Success", response.message || "Bank details updated successfully!");
|
ToastAndroid.show(response.message || "Bank details updated successfully!", ToastAndroid.SHORT);
|
||||||
navigation.goBack();
|
navigation.goBack();
|
||||||
} else {
|
} else {
|
||||||
Alert.alert("Update Failed", response.message || "Could not update bank details.");
|
ToastAndroid.show(response.message || "Could not update bank details.", ToastAndroid.SHORT);
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error("Error updating bank details:", error);
|
console.error("Error updating bank details:", error);
|
||||||
// Alert.alert("Error", error.message || "An unexpected error occurred. Please try again.");
|
ToastAndroid.show(error.message || "An unexpected error occurred. Please try again.", ToastAndroid.SHORT);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
KeyboardAvoidingView,
|
KeyboardAvoidingView,
|
||||||
Platform,
|
Platform,
|
||||||
RefreshControl,
|
RefreshControl,
|
||||||
|
ToastAndroid,
|
||||||
} 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";
|
||||||
@@ -69,7 +70,7 @@ const Profile = () => {
|
|||||||
try {
|
try {
|
||||||
const credentials = await Keychain.getGenericPassword();
|
const credentials = await Keychain.getGenericPassword();
|
||||||
if (!credentials) {
|
if (!credentials) {
|
||||||
Alert.alert("Error", "You are not logged in");
|
ToastAndroid.show('You are not logged in', ToastAndroid.SHORT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const token = credentials.password;
|
const token = credentials.password;
|
||||||
@@ -114,11 +115,10 @@ const Profile = () => {
|
|||||||
profileStatus: true, // set true once profile is fetched
|
profileStatus: true, // set true once profile is fetched
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
Alert.alert("Error", "Failed to fetch user profile");
|
ToastAndroid.show("Failed to fetch user profile", ToastAndroid.SHORT);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("❌ Error fetching profile:", error);
|
console.error("❌ Error fetching profile:", error);
|
||||||
// Alert.alert("Error", "Could not connect to server");
|
|
||||||
} finally {
|
} finally {
|
||||||
setFetching(false);
|
setFetching(false);
|
||||||
}
|
}
|
||||||
@@ -129,7 +129,7 @@ const Profile = () => {
|
|||||||
try {
|
try {
|
||||||
const credentials = await Keychain.getGenericPassword();
|
const credentials = await Keychain.getGenericPassword();
|
||||||
if (!credentials) {
|
if (!credentials) {
|
||||||
Alert.alert("Error", "You are not logged in");
|
ToastAndroid.show('You are not logged in', ToastAndroid.SHORT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const token = credentials.password;
|
const token = credentials.password;
|
||||||
@@ -157,20 +157,16 @@ const Profile = () => {
|
|||||||
|
|
||||||
|
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
console.log("result for profile update :", result);
|
|
||||||
// Alert.alert("Success", "Profile updated successfully");
|
|
||||||
// setEditing(false);
|
|
||||||
// fetchUserProfile();
|
|
||||||
if (result.status === "success") {
|
if (result.status === "success") {
|
||||||
Alert.alert("Success", "Profile updated successfully");
|
ToastAndroid.show("Profile updated successfully", ToastAndroid.SHORT);
|
||||||
setEditing(false);
|
setEditing(false);
|
||||||
fetchUserProfile(); // reload updated data
|
fetchUserProfile(); // reload updated data
|
||||||
} else {
|
} else {
|
||||||
Alert.alert("Error", "Failed to update profile");
|
ToastAndroid.show("Failed to update profile", ToastAndroid.SHORT);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("❌ Error updating profile:", error);
|
console.error("❌ Error updating profile:", error);
|
||||||
// Alert.alert("Error", "Could not update profile");
|
ToastAndroid.show("Could not update profile", ToastAndroid.SHORT);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -179,7 +175,7 @@ const Profile = () => {
|
|||||||
launchImageLibrary({ mediaType: "photo", quality: 0.5 }, (response) => {
|
launchImageLibrary({ mediaType: "photo", quality: 0.5 }, (response) => {
|
||||||
if (response.didCancel) return;
|
if (response.didCancel) return;
|
||||||
if (response.errorCode) {
|
if (response.errorCode) {
|
||||||
Alert.alert("Error", response.errorMessage || "Something went wrong");
|
ToastAndroid.show(response.errorMessage || "Something went wrong", ToastAndroid.SHORT);
|
||||||
} else if (response.assets && response.assets.length > 0) {
|
} else if (response.assets && response.assets.length > 0) {
|
||||||
const selectedImage = response.assets[0];
|
const selectedImage = response.assets[0];
|
||||||
setUser((prev: any) =>
|
setUser((prev: any) =>
|
||||||
@@ -194,14 +190,14 @@ const Profile = () => {
|
|||||||
try {
|
try {
|
||||||
const credentials = await Keychain.getGenericPassword();
|
const credentials = await Keychain.getGenericPassword();
|
||||||
if (!credentials) {
|
if (!credentials) {
|
||||||
Alert.alert("Error", "You are not logged in");
|
ToastAndroid.show('You are not logged in', ToastAndroid.SHORT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const token = credentials.password;
|
const token = credentials.password;
|
||||||
|
|
||||||
|
|
||||||
if (!user?.filePath) {
|
if (!user?.filePath) {
|
||||||
Alert.alert("Error", "Please select an image first");
|
ToastAndroid.show("Please select an image first", ToastAndroid.SHORT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,8 +228,7 @@ const Profile = () => {
|
|||||||
|
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
if (result.status === "success") {
|
if (result.status === "success") {
|
||||||
Alert.alert("Success", "Profile image updated successfully");
|
ToastAndroid.show("Profile image updated successfully", ToastAndroid.SHORT);
|
||||||
|
|
||||||
|
|
||||||
// If API returns updated image, set it
|
// If API returns updated image, set it
|
||||||
if (result.data?.imageBlob) {
|
if (result.data?.imageBlob) {
|
||||||
@@ -247,11 +242,11 @@ const Profile = () => {
|
|||||||
// Refresh profile from API as well
|
// Refresh profile from API as well
|
||||||
fetchUserProfile();
|
fetchUserProfile();
|
||||||
} else {
|
} else {
|
||||||
Alert.alert("Error", result.message || "Failed to update profile image");
|
ToastAndroid.show(result.message || "Failed to update profile image", ToastAndroid.SHORT);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("❌ Error updating profile image:", error);
|
console.error("❌ Error updating profile image:", error);
|
||||||
// Alert.alert("Error", "Could not update profile image");
|
ToastAndroid.show("Could not update profile image", ToastAndroid.SHORT);
|
||||||
} finally {
|
} finally {
|
||||||
setImageUpdating(false);
|
setImageUpdating(false);
|
||||||
}
|
}
|
||||||
@@ -262,7 +257,7 @@ const Profile = () => {
|
|||||||
try {
|
try {
|
||||||
const credentials = await Keychain.getGenericPassword();
|
const credentials = await Keychain.getGenericPassword();
|
||||||
if (!credentials) {
|
if (!credentials) {
|
||||||
Alert.alert("Error", "You are not logged in");
|
ToastAndroid.show('You are not logged in', ToastAndroid.SHORT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const token = credentials.password;
|
const token = credentials.password;
|
||||||
@@ -305,7 +300,7 @@ const Profile = () => {
|
|||||||
|
|
||||||
|
|
||||||
if (!credentials) {
|
if (!credentials) {
|
||||||
Alert.alert("Info", "No user is currently logged in");
|
ToastAndroid.show('No user is currently logged in', ToastAndroid.SHORT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,11 +309,10 @@ const Profile = () => {
|
|||||||
// Clear stored credentials
|
// Clear stored credentials
|
||||||
await Keychain.resetGenericPassword();
|
await Keychain.resetGenericPassword();
|
||||||
dispatch(clearUser())
|
dispatch(clearUser())
|
||||||
Alert.alert("Success", "You have been logged out");
|
ToastAndroid.show("You have been logged out", ToastAndroid.SHORT);
|
||||||
navigation.replace("Login");
|
navigation.replace("Login");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Logout error:", error);
|
console.error("Logout error:", error);
|
||||||
// Alert.alert("Error", "Failed to log out. Please try again.");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ import { useDispatch } from "react-redux";
|
|||||||
import { BASE_URL } from "./ApiUrls";
|
import { BASE_URL } from "./ApiUrls";
|
||||||
import * as Keychain from "react-native-keychain";
|
import * as Keychain from "react-native-keychain";
|
||||||
import { setUserData } from "../redux/userSlice";
|
import { setUserData } from "../redux/userSlice";
|
||||||
import { Alert } from "react-native";
|
import { Alert, ToastAndroid } from "react-native";
|
||||||
|
|
||||||
export const fetchUserProfile = async () => {
|
export const fetchUserProfile = async () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
try {
|
try {
|
||||||
const credentials = await Keychain.getGenericPassword();
|
const credentials = await Keychain.getGenericPassword();
|
||||||
if (!credentials) {
|
if (!credentials) {
|
||||||
// Alert.alert("Error", "You are not logged in");
|
// ToastAndroid.show('You are not logged in', ToastAndroid.SHORT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const token = credentials.password;
|
const token = credentials.password;
|
||||||
@@ -52,11 +52,11 @@ export const fetchUserProfile = async () => {
|
|||||||
|
|
||||||
console.log("splash user data:", result.data);
|
console.log("splash user data:", result.data);
|
||||||
} else {
|
} else {
|
||||||
Alert.alert("Error", "Failed to fetch user profile");
|
ToastAndroid.show(result.message || "Failed to fetch user profile", ToastAndroid.SHORT);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("❌ Error fetching profile:", error);
|
console.error("❌ Error fetching profile:", error);
|
||||||
// Alert.alert("Error", "Could not connect to server");
|
ToastAndroid.show("Could not connect to server", ToastAndroid.SHORT);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user