diff --git a/src/screens/GroupCreation.tsx b/src/screens/GroupCreation.tsx index 713bb3e..7fb6308 100644 --- a/src/screens/GroupCreation.tsx +++ b/src/screens/GroupCreation.tsx @@ -48,7 +48,7 @@ export default function GroupCreationForm() { minParticipants: "", startDate: "", visibility: "PRIVATE", - fundDistribution: "SEQUENTIAL", + withdrawalMethod: "SEQUENTIAL", }); const [errors, setErrors] = useState({}); // State for validation errors @@ -96,6 +96,7 @@ export default function GroupCreationForm() { const handleReview = () => { if (validateForm()) { + console.log("------",form) navigation.navigate("GroupReview", { form }); } else { Alert.alert("Incomplete Form", "Please fill out all required fields correctly."); @@ -121,7 +122,7 @@ export default function GroupCreationForm() { Fund Distribution - {distributionTypes.map((type) => ( handleChange("fundDistribution", type)} style={[styles.toggleButton, form.fundDistribution === type && styles.selectedButton]}>{type.charAt(0) + type.slice(1).toLowerCase()}))} + {distributionTypes.map((type) => ( handleChange("withdrawalMethod", type)} style={[styles.toggleButton, form.withdrawalMethod === type && styles.selectedButton]}>{type.charAt(0) + type.slice(1).toLowerCase()}))} diff --git a/src/screens/GroupReview.tsx b/src/screens/GroupReview.tsx index c189865..a0f91dd 100644 --- a/src/screens/GroupReview.tsx +++ b/src/screens/GroupReview.tsx @@ -82,6 +82,7 @@ export default function GroupReview({ route, navigation }: any) { maxParticipants: Number(form.maxParticipants) || 0, minParticipants: Number(form.minParticipants) || 0, }; + console.log("payload:", payload); const res = await apiCall(GROUP_CREATION_URL, "POST", payload) as { statusCode?: number }; if (res?.statusCode === 201) { @@ -111,7 +112,7 @@ export default function GroupReview({ route, navigation }: any) { {/* --- Timeline Sections --- */} {renderRow("Name", form.groupName)}{form.description ? ( Description {form.description} ) : null} - {renderRow("Visibility", form.visibility)}{renderRow("Distribution", form.fundDistribution)}{renderRow("Min Members", form.minParticipants)}{renderRow("Max Members", form.maxParticipants)} + {renderRow("Visibility", form.visibility)}{renderRow("Distribution", form.withdrawalMethod)}{renderRow("Min Members", form.minParticipants)}{renderRow("Max Members", form.maxParticipants)} {renderRow("Contribution", `${form.contributionAmount} INR`)}{renderRow("Cycle", form.cycleType)}{form.cycleType === "CUSTOM" && renderRow("Cycle Days", `${form.customCycleDays} days`)}{renderRow("Start Date", form.startDate)} diff --git a/src/screens/SplashScreen.tsx b/src/screens/SplashScreen.tsx index 2fd28a6..ff214e1 100644 --- a/src/screens/SplashScreen.tsx +++ b/src/screens/SplashScreen.tsx @@ -21,7 +21,7 @@ const SplashScreen = () => { try { const credentials = await Keychain.getGenericPassword(); if (!credentials) { - + // Alert.alert("Error", "You are not logged in"); return; } const token = credentials.password; diff --git a/src/screens/home/UserProfileStatus.tsx b/src/screens/home/UserProfileStatus.tsx index 9349c05..f031f9b 100644 --- a/src/screens/home/UserProfileStatus.tsx +++ b/src/screens/home/UserProfileStatus.tsx @@ -11,6 +11,7 @@ import { import * as Keychain from "react-native-keychain"; import { useFocusEffect, useNavigation } from "@react-navigation/native"; import { BASE_URL } from "../../utils/ApiUrls"; +import colors from "../../components/colors"; export type ApiResponse = { message: string; @@ -136,13 +137,14 @@ const UserProfileStatus: React.FC = () => { { if (intervalId) { - clearInterval(intervalId); - setIntervalId(null); - } + onPress={() => { + if (intervalId) { + clearInterval(intervalId); + setIntervalId(null); + } - setShowModal(false); - }} + setShowModal(false); + }} > Close @@ -221,7 +223,7 @@ const styles = StyleSheet.create({ fontSize: 20, fontWeight: "700", marginBottom: 10, - color: "#FF9500", + color: colors.primary, }, modalText: { fontSize: 14, diff --git a/src/screens/management/EditGroupScreen.tsx b/src/screens/management/EditGroupScreen.tsx index 2d2dcec..b56280b 100644 --- a/src/screens/management/EditGroupScreen.tsx +++ b/src/screens/management/EditGroupScreen.tsx @@ -116,6 +116,7 @@ const EditGroupScreen: React.FC = ({ route, navigation }) } setLoading(true); try { + console.log(`Fetching details for group ID: ${groupId}`); const response = await apiCall( `https://api.godemo.in/FundCollect/api/fund/group/details?groupId=${groupId}`, 'GET', diff --git a/src/screens/management/ManagementScreen.tsx b/src/screens/management/ManagementScreen.tsx index 5bfea6b..1c8ab5d 100644 --- a/src/screens/management/ManagementScreen.tsx +++ b/src/screens/management/ManagementScreen.tsx @@ -14,7 +14,7 @@ import { import { useNavigation, useFocusEffect } from "@react-navigation/native"; import { StackNavigationProp } from "@react-navigation/stack"; import { RootStackParamList } from "../../navigation/AppNavigator"; -import { APPROVE_REQUEST_URL, BASE_URL, DECLINE_REQUEST_URL, MY_GROUPS_URL, REQUESTS_URL } from "../../utils/ApiUrls"; +import { APPROVE_REQUEST_URL, BASE_URL, DECLINE_REQUEST_URL, JOIN_GROUP_URL, MY_GROUPS_URL, REQUESTS_URL } from "../../utils/ApiUrls"; import colors from "../../components/colors"; import AppView from "../../components/AppView"; import { apiCall } from "../../utils/ApiHelper"; @@ -46,7 +46,7 @@ const ManagementScreen: FC = () => { // Fetch all data concurrently const [myGroupsRes,joinedGroupsRes,requestsRes] = await Promise.all([ apiCall(MY_GROUPS_URL, "GET") as Promise>, - apiCall(DECLINE_REQUEST_URL, "GET") as Promise>, // Assuming this is also needed + apiCall(JOIN_GROUP_URL, "GET") as Promise>, // Assuming this is also needed apiCall(REQUESTS_URL, "GET") as Promise>, ]); diff --git a/src/screens/profile/BecomeOrg.tsx b/src/screens/profile/BecomeOrg.tsx index cbe6225..1ac795c 100644 --- a/src/screens/profile/BecomeOrg.tsx +++ b/src/screens/profile/BecomeOrg.tsx @@ -9,12 +9,17 @@ import { KeyboardAvoidingView, Platform, SafeAreaView, + TouchableOpacity, } from "react-native"; import * as Keychain from "react-native-keychain"; import { CustomInput, CustomButton } from "../../components/common/Custom"; import colors from "../../components/colors"; +import { useNavigation } from "@react-navigation/native"; +import AppView from "../../components/AppView"; +import Ionicons from "@react-native-vector-icons/ionicons"; const BecomeOrg = () => { + const navigation = useNavigation(); const [bankAccountNumber, setBankAccountNumber] = useState(""); const [bankName, setBankName] = useState(""); const [branchCode, setBranchCode] = useState(""); @@ -58,6 +63,7 @@ const BecomeOrg = () => { setBankAccountNumber(""); setBankName(""); setBranchCode(""); + navigation.navigate("Home" as never); } else { Alert.alert("Error", result.message || "Failed to apply"); } @@ -70,7 +76,14 @@ const BecomeOrg = () => { }; return ( - + + + navigation.replace("Home" as never)} > + + + User Profile + + { )} - + ); }; @@ -140,4 +153,17 @@ const styles = StyleSheet.create({ textAlign: "center", color: colors.textDark, }, + header: { + flexDirection: "row", + justifyContent: "space-between", + alignItems: "center", + padding: 16, + borderBottomLeftRadius: 20, + borderBottomRightRadius: 20, + }, + headerTitle: { + fontSize: 22, + fontWeight: "700", + color: "#000" + }, }); diff --git a/src/screens/profile/Profile.tsx b/src/screens/profile/Profile.tsx index 36ef8f5..4b9147e 100644 --- a/src/screens/profile/Profile.tsx +++ b/src/screens/profile/Profile.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect, useCallback} from "react"; +import React, { useState, useEffect, useCallback } from "react"; import { StyleSheet, View, @@ -243,35 +243,35 @@ const Profile = () => { } }; - const logout = async (navigation: any) => { - try { - const credentials = await Keychain.getGenericPassword(); + const logout = async (navigation: any) => { + try { + const credentials = await Keychain.getGenericPassword(); - if (!credentials) { - Alert.alert("Info", "No user is currently logged in"); - return; + if (!credentials) { + Alert.alert("Info", "No user is currently logged in"); + return; + } + + // Clear stored credentials + await Keychain.resetGenericPassword(); + Alert.alert("Success", "You have been logged out"); + navigation.replace("Login"); + } catch (error) { + console.error("Logout error:", error); + Alert.alert("Error", "Failed to log out. Please try again."); } + }; - // Clear stored credentials - await Keychain.resetGenericPassword(); - Alert.alert("Success", "You have been logged out"); - navigation.replace("Login"); - } catch (error) { - console.error("Logout error:", error); - Alert.alert("Error", "Failed to log out. Please try again."); - } -}; - - const confirmLogout = (navigation: any) => { - Alert.alert( - "Logout", - "Are you sure you want to log out?", - [ - { text: "Cancel", style: "cancel" }, - { text: "Yes, Logout", style: "destructive", onPress: () => logout(navigation) }, - ] - ); -}; + const confirmLogout = (navigation: any) => { + Alert.alert( + "Logout", + "Are you sure you want to log out?", + [ + { text: "Cancel", style: "cancel" }, + { text: "Yes, Logout", style: "destructive", onPress: () => logout(navigation) }, + ] + ); + }; useFocusEffect( @@ -281,7 +281,7 @@ const Profile = () => { ); useEffect(() => { - userStatus(); + userStatus(); fetchUserProfile(); }, []); @@ -316,7 +316,7 @@ const Profile = () => { { {/* Profile Card */} {/* Profile Image Section */} - {/* { - statusData?.role && statusData?.organizerStatus ? - Your Role: {statusData.role} | Organizer Status: {statusData.organizerStatus} - : - } */} + { user?.role === "ORGANIZER" && user?.organizerStatus === "NOT_APPLIED" || "PENDING" ? ( + Your Role: {user.role} | Organizer Status: {user.organizerStatus} + ) : ( + + )} { <> {/* Profile Details */} - Personal Information - + + + Personal Information + Become Organizer + {/* - Become Organizer + + */} + + + setEditing(true)} + icon="create" + style={styles.editButton} + buttonBackground={colors.pastelBlue} + /> + - @@ -419,15 +432,11 @@ const Profile = () => { {user.role || "User"} - - setEditing(true)} - icon="create" - style={styles.editButton} - buttonBackground={colors.pastelBlue} - /> + + + + ) : ( <> @@ -482,22 +491,24 @@ const Profile = () => { onChangeText={(text) => setUser({ ...user, gender: text })} icon="male-female" /> - - - - setEditing(false)} - icon="close" - style={styles.cancelButton} - buttonBackground="#f38080ff" - /> + + + + setEditing(false)} + icon="close" + style={styles.cancelButton} + buttonBackground="" + /> + + )} @@ -530,15 +541,8 @@ const styles = StyleSheet.create({ justifyContent: "space-between", alignItems: "center", padding: 16, - // paddingTop: 50, - // backgroundColor: "#6366f1", borderBottomLeftRadius: 20, borderBottomRightRadius: 20, - // elevation: 4, - // shadowColor: "#000", - // shadowOffset: { width: 0, height: 2 }, - // shadowOpacity: 0.2, - // shadowRadius: 4, }, headerTitle: { fontSize: 22, @@ -598,13 +602,13 @@ const styles = StyleSheet.create({ borderRadius: 25, }, detailsSection: { - marginBottom: 24, + marginBottom: "40%", }, sectionTitle: { fontSize: 18, fontWeight: "700", color: "#1e293b", - marginBottom: 16, + // marginBottom: 16, paddingBottom: 8, borderBottomWidth: 1, borderBottomColor: "#f1f5f9", @@ -629,10 +633,10 @@ const styles = StyleSheet.create({ fontWeight: "500", }, editButton: { - marginTop: 8, + paddingHorizontal: 8, }, editSection: { - marginBottom: 20, + marginBottom: '40%', flex: 1, }, editButtons: { @@ -643,6 +647,8 @@ const styles = StyleSheet.create({ }, cancelButton: { marginTop: 4, + borderWidth: 1, + borderColor: "#cbd5e1", }, inputContainer: { marginBottom: 16, diff --git a/src/screens/profile/SwitchNavigator.tsx b/src/screens/profile/SwitchNavigator.tsx index 5a26a3a..bee3379 100644 --- a/src/screens/profile/SwitchNavigator.tsx +++ b/src/screens/profile/SwitchNavigator.tsx @@ -2,6 +2,7 @@ import React, { useState } from "react"; import { View, Text, StyleSheet, Switch } from "react-native"; import { useNavigation } from "@react-navigation/native"; import type { NativeStackNavigationProp } from "@react-navigation/native-stack"; +import colors from "../../components/colors"; type RootStackParamList = { BecomeOrg: undefined; @@ -24,6 +25,10 @@ const SwitchNavigator: React.FC = ({ role, status }) => { if (newValue) { navigation.navigate("BecomeOrg"); // Navigate when ON + setTimeout(() => { + setIsEnabled(false); + }, 2000); + // Reset switch to OFF after navigation } else { navigation.navigate("Profile"); // Navigate when OFF } @@ -40,8 +45,8 @@ const SwitchNavigator: React.FC = ({ role, status }) => { : `Request Organizer Role ${status}`}