From 3b1dc584054b261ca2d84dc3e92a786d0c07d635 Mon Sep 17 00:00:00 2001 From: Jaanu423 Date: Fri, 19 Sep 2025 12:26:57 +0530 Subject: [PATCH 1/2] added fetch contact from real device icon --- android/app/src/main/AndroidManifest.xml | 2 + .../java/com/circlecollect/ContactsModule.kt | 48 ++++ .../java/com/circlecollect/ContactsPackage.kt | 16 ++ .../java/com/circlecollect/MainApplication.kt | 2 + src/components/RequestCard.tsx | 14 +- src/fetchContacts.ts | 29 +++ src/navigation/AppNavigator.tsx | 4 +- src/screens/management/ManagementScreen.tsx | 43 +++- src/screens/management/YourContacts.tsx | 229 ++++++++++++++++++ src/screens/profile/Profile.tsx | 21 +- 10 files changed, 382 insertions(+), 26 deletions(-) create mode 100644 android/app/src/main/java/com/circlecollect/ContactsModule.kt create mode 100644 android/app/src/main/java/com/circlecollect/ContactsPackage.kt create mode 100644 src/fetchContacts.ts create mode 100644 src/screens/management/YourContacts.tsx diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index f8fef7e..2461564 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,8 @@ + + { + return listOf(ContactsModule(reactContext)) + } + + override fun createViewManagers(reactContext: ReactApplicationContext): List> { + return emptyList() + } +} diff --git a/android/app/src/main/java/com/circlecollect/MainApplication.kt b/android/app/src/main/java/com/circlecollect/MainApplication.kt index f4394e6..e411077 100644 --- a/android/app/src/main/java/com/circlecollect/MainApplication.kt +++ b/android/app/src/main/java/com/circlecollect/MainApplication.kt @@ -9,6 +9,7 @@ import com.facebook.react.ReactNativeHost import com.facebook.react.ReactPackage import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost import com.facebook.react.defaults.DefaultReactNativeHost +import com.circlecollect.ContactsPackage class MainApplication : Application(), ReactApplication { @@ -18,6 +19,7 @@ class MainApplication : Application(), ReactApplication { PackageList(this).packages.apply { // Packages that cannot be autolinked yet can be added manually here, for example: // add(MyReactNativePackage()) + add(ContactsPackage()) } override fun getJSMainModuleName(): String = "index" diff --git a/src/components/RequestCard.tsx b/src/components/RequestCard.tsx index 57eb7a2..b0ac2fd 100644 --- a/src/components/RequestCard.tsx +++ b/src/components/RequestCard.tsx @@ -23,7 +23,7 @@ export const RequestCard: FC = ({ item, onApprove, onDecline } /> {item.userName} - {item.mobile} + {item.mobile} @@ -37,13 +37,13 @@ export const RequestCard: FC = ({ item, onApprove, onDecline } {/* Bottom section with action buttons */} onDecline(item)}> - - Decline + + Decline onApprove(item)}> {/* Corrected icon color and updated text color for better contrast */} - - Approve + + Approve @@ -77,7 +77,7 @@ const styles = StyleSheet.create({ flexDirection: 'row', alignItems: 'center', borderBottomWidth: 1, - borderBottomColor: colors.border, + borderBottomColor: colors.textLight, paddingBottom: 12, }, avatar: { @@ -125,7 +125,7 @@ const styles = StyleSheet.create({ borderRadius: 12, }, declineButton: { - backgroundColor: colors.lightDanger, + backgroundColor: colors.pastelPink, }, approveButton: { // Set background color as requested diff --git a/src/fetchContacts.ts b/src/fetchContacts.ts new file mode 100644 index 0000000..b6b1617 --- /dev/null +++ b/src/fetchContacts.ts @@ -0,0 +1,29 @@ +import { PermissionsAndroid, Platform, NativeModules } from "react-native"; + +const { ContactsModule } = NativeModules; + +async function fetchContacts() { + if (Platform.OS === "android") { + const granted = await PermissionsAndroid.request( + PermissionsAndroid.PERMISSIONS.READ_CONTACTS, + { + title: "Contacts Permission", + message: "This app would like to view your contacts.", + buttonPositive: "OK", + } + ); + + if (granted !== PermissionsAndroid.RESULTS.GRANTED) { + console.log("Contacts permission denied"); + return; + } + } + + try { + const contacts = await ContactsModule.getContacts(); + console.log("Contacts:", contacts); + } catch (error) { + console.error("Error fetching contacts:", error); + } +} +export { fetchContacts }; \ No newline at end of file diff --git a/src/navigation/AppNavigator.tsx b/src/navigation/AppNavigator.tsx index 2da5c4a..7390d57 100644 --- a/src/navigation/AppNavigator.tsx +++ b/src/navigation/AppNavigator.tsx @@ -12,6 +12,7 @@ import GroupReview from "../screens/GroupReview"; import BottomTabs from "./BottomTabs"; import BecomeOrg from "../screens/profile/BecomeOrg"; import EditGroupScreen from "../screens/management/EditGroupScreen"; +import YourContacts from "../screens/management/YourContacts"; const Stack = createNativeStackNavigator(); export type RootStackParamList = { @@ -62,7 +63,8 @@ export default function AppNavigator() { - + + {/* */} ); diff --git a/src/screens/management/ManagementScreen.tsx b/src/screens/management/ManagementScreen.tsx index 5bfea6b..20ab954 100644 --- a/src/screens/management/ManagementScreen.tsx +++ b/src/screens/management/ManagementScreen.tsx @@ -23,6 +23,7 @@ import { MyGroup, JoinedGroup, JoinRequest, ApiResponse } from '../../types'; import { MyGroupCard } from "../../components/MyGroupCard"; import { JoinedGroupCard } from "../../components/JoinedGroupCard"; import { RequestCard } from "../../components/RequestCard"; +import Ionicons from "@react-native-vector-icons/ionicons"; type GroupManagementNavProp = StackNavigationProp; type ActiveTab = "My Groups" | "Joined Groups" | "Requests"; @@ -44,7 +45,7 @@ const ManagementScreen: FC = () => { try { if (userRole === "ORGANIZER") { // Fetch all data concurrently - const [myGroupsRes,joinedGroupsRes,requestsRes] = await Promise.all([ + 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(REQUESTS_URL, "GET") as Promise>, @@ -74,7 +75,7 @@ const ManagementScreen: FC = () => { const handleAction = async (url: string, body: object, successMessage: string, failureMessage: string, action: string) => { // ... (logic remains the same) console.log(url) - try { + try { setLoading(true); // Optionally show a loading state during the action // Make the POST request with an empty body const res = await apiCall(url, "PUT", {}) as ApiResponse | null; @@ -93,15 +94,15 @@ const ManagementScreen: FC = () => { } }; - const handleApprove = (req: JoinRequest) => handleAction(APPROVE_REQUEST_URL+req.requestId+"/approve", { requestId: req.requestId }, `${req.userName} has been added.`, "Failed to approve request.","Approve"); - const handleDecline = (req: JoinRequest) => handleAction(DECLINE_REQUEST_URL+req.requestId+"/reject?reason=/"+" ", { requestId: req.requestId }, `Request from ${req.userName} has been declined.`, "Failed to decline request.","Decline"); + const handleApprove = (req: JoinRequest) => handleAction(APPROVE_REQUEST_URL + req.requestId + "/approve", { requestId: req.requestId }, `${req.userName} has been added.`, "Failed to approve request.", "Approve"); + const handleDecline = (req: JoinRequest) => handleAction(DECLINE_REQUEST_URL + req.requestId + "/reject?reason=/" + " ", { requestId: req.requestId }, `Request from ${req.userName} has been declined.`, "Failed to decline request.", "Decline"); const handleManageGroup = (group: MyGroup) => navigation.navigate('EditGroup', { groupId: group.id }); const renderContent = () => { if (error) { return {error}; } - + switch (activeTab) { case "My Groups": if (loading) { @@ -151,9 +152,9 @@ const ManagementScreen: FC = () => { default: return null; } }; - + const tabs: ActiveTab[] = userRole === 'ORGANIZER' ? ["My Groups", "Joined Groups", "Requests"] : ["Joined Groups"]; - + return ( @@ -167,6 +168,32 @@ const ManagementScreen: FC = () => { ))} + { + activeTab === "Requests" && userRole === "ORGANIZER" ? ( + navigation.navigate("YourContacts" as never)} + > + + + ) : null + } + {renderContent()} @@ -176,7 +203,7 @@ const ManagementScreen: FC = () => { const styles = StyleSheet.create({ container: { flex: 1, - backgroundColor: '#f5f6fa' + backgroundColor: '#f5f6fa' }, header: { paddingHorizontal: 20, diff --git a/src/screens/management/YourContacts.tsx b/src/screens/management/YourContacts.tsx new file mode 100644 index 0000000..1dc2137 --- /dev/null +++ b/src/screens/management/YourContacts.tsx @@ -0,0 +1,229 @@ +import React, { useState, useEffect } from "react"; +import { + StyleSheet, + Text, + View, + FlatList, + TouchableOpacity, + Modal, + PermissionsAndroid, + Platform, + NativeModules, +} from "react-native"; + +const { ContactsModule } = NativeModules; + +const YourContacts = () => { + const [contacts, setContacts] = useState([]); + const [selectedContact, setSelectedContact] = useState(null); + const [modalVisible, setModalVisible] = useState(false); + + useEffect(() => { + handleFetchContacts(); + }, []); + + const handleFetchContacts = async () => { + try { + if (Platform.OS === "android") { + const granted = await PermissionsAndroid.request( + PermissionsAndroid.PERMISSIONS.READ_CONTACTS, + { + title: "Contacts Permission", + message: "This app would like to view your contacts.", + buttonPositive: "OK", + } + ); + + if (granted !== PermissionsAndroid.RESULTS.GRANTED) { + console.log("Contacts permission denied"); + return; + } + } + + const fetchedContacts = await ContactsModule.getContacts(); + setContacts(fetchedContacts); + } catch (error) { + console.error("Error fetching contacts:", error); + } + }; + + const handleSend = (contact: any) => { + setSelectedContact(contact); + setModalVisible(true); + }; + + const renderContact = ({ item }: { item: any }) => ( + + + + {item.name ? item.name.charAt(0).toUpperCase() : "?"} + + + + {item.name} + {item.phone} + + handleSend(item)} + > + Invite + + + ); + + return ( + + Select Contact + index.toString()} + renderItem={renderContact} + /> + + {/* Send Modal */} + setModalVisible(false)} + > + + + Send Invite + {selectedContact && ( + + Send invite to {selectedContact.name} ({selectedContact.phone})? + + )} + + setModalVisible(false)} + > + Cancel + + setModalVisible(false)} + > + Send + + + + + + + ); +}; + +export default YourContacts; + +const styles = StyleSheet.create({ + container: { + flex: 1, + backgroundColor: "#fff", + paddingHorizontal: 10, + paddingTop: 20, + }, + header: { + fontSize: 20, + fontWeight: "bold", + marginBottom: 15, + }, + contactRow: { + flexDirection: "row", + alignItems: "center", + paddingVertical: 12, + borderBottomWidth: 0.5, + borderBottomColor: "#ddd", + }, + avatar: { + width: 45, + height: 45, + borderRadius: 25, + backgroundColor: "#25D366", + justifyContent: "center", + alignItems: "center", + marginRight: 12, + }, + avatarText: { + color: "#fff", + fontSize: 18, + fontWeight: "bold", + }, + contactInfo: { + flex: 1, + }, + contactName: { + fontSize: 16, + fontWeight: "600", + }, + contactPhone: { + fontSize: 13, + color: "gray", + }, + inviteButton: { + paddingHorizontal: 14, + paddingVertical: 6, + borderRadius: 8, + borderWidth: 1, + borderColor: "#25D366", + }, + inviteText: { + color: "#25D366", + fontWeight: "bold", + }, + modalOverlay: { + flex: 1, + backgroundColor: "rgba(0,0,0,0.5)", + justifyContent: "center", + alignItems: "center", + }, + modalContent: { + width: "80%", + backgroundColor: "#fff", + borderRadius: 10, + padding: 20, + alignItems: "center", + }, + modalTitle: { + fontSize: 18, + fontWeight: "bold", + marginBottom: 10, + }, + modalText: { + fontSize: 15, + marginBottom: 20, + textAlign: "center", + }, + modalActions: { + flexDirection: "row", + justifyContent: "space-between", + width: "100%", + }, + cancelButton: { + flex: 1, + marginRight: 10, + paddingVertical: 10, + borderRadius: 8, + backgroundColor: "#ddd", + alignItems: "center", + }, + cancelText: { + fontWeight: "bold", + color: "#333", + }, + sendButton: { + flex: 1, + marginLeft: 10, + paddingVertical: 10, + borderRadius: 8, + backgroundColor: "#25D366", + alignItems: "center", + }, + sendText: { + fontWeight: "bold", + color: "#fff", + }, +}); diff --git a/src/screens/profile/Profile.tsx b/src/screens/profile/Profile.tsx index 378ba90..87b24db 100644 --- a/src/screens/profile/Profile.tsx +++ b/src/screens/profile/Profile.tsx @@ -23,6 +23,7 @@ import { useFocusEffect, useNavigation } from "@react-navigation/native"; import { ApiResponse } from "../home/UserProfileStatus"; import { BASE_URL } from "../../utils/ApiUrls"; import AppView from "../../components/AppView"; +import { useSelector } from "react-redux"; @@ -47,6 +48,7 @@ type UserProfile = { const Profile = () => { const navigation = useNavigation(); + const user1 = useSelector((state: any) => state.user); const [user, setUser] = useState(null); const [fetching, setFetching] = useState(true); const [editing, setEditing] = useState(false); @@ -222,7 +224,7 @@ const Profile = () => { const response = await fetch(`${BASE_URL}user/profile/status`, { method: "GET", headers: { - Accept: "/", + Accept: "*/*", Authorization: `Bearer ${token}`, }, }); @@ -232,6 +234,7 @@ const Profile = () => { console.log("👤 Profile Status Response:", json); if (json.status === "success") { setStatusData(json.data); + console.log("statusData response :", json); } else { setError(json.message || "Failed to fetch status"); @@ -273,6 +276,8 @@ const Profile = () => { ); }; + console.log("statusData?.role :", statusData?.role); + console.log("statusData?.organizerStatus :", statusData?.organizerStatus); useFocusEffect( useCallback(() => { @@ -327,15 +332,11 @@ const Profile = () => { {/* Profile Card */} {/* Profile Image Section */} - {user?.role !== "USER" - && - (user?.role === "ORGANIZER" && - (user?.organizerStatus === "NOT_APPLIED" || user?.organizerStatus !== "PENDING")) ? ( - Your Role: {user.role} | Organizer Status: {user.organizerStatus} - ) : ( - - - )} + { + statusData?.role && statusData?.organizerStatus ? + Your Role: {statusData.role} | Organizer Status: {statusData.organizerStatus} + : + } Date: Fri, 19 Sep 2025 13:22:30 +0530 Subject: [PATCH 2/2] added fetch contact from real device icon --- src/screens/OtpVarificationScreen.tsx | 2 +- src/screens/management/YourContacts.tsx | 455 +++++++++++++----------- src/screens/profile/Profile.tsx | 27 +- src/screens/profile/SwitchNavigator.tsx | 22 +- 4 files changed, 281 insertions(+), 225 deletions(-) diff --git a/src/screens/OtpVarificationScreen.tsx b/src/screens/OtpVarificationScreen.tsx index c611f49..162a27e 100644 --- a/src/screens/OtpVarificationScreen.tsx +++ b/src/screens/OtpVarificationScreen.tsx @@ -105,7 +105,7 @@ export default function OtpVerificationScreen() { { headers: { "Content-Type": "application/json", Accept: "*/*" } } ); - console.log("📩 OTP Resent:", res.data); + console.log("📩 OTP Resent:", res); setCode(Array(CELL_COUNT).fill("")); inputs.current[0]?.focus(); ToastAndroid.show("OTP Sent", ToastAndroid.SHORT); diff --git a/src/screens/management/YourContacts.tsx b/src/screens/management/YourContacts.tsx index 1dc2137..d256c99 100644 --- a/src/screens/management/YourContacts.tsx +++ b/src/screens/management/YourContacts.tsx @@ -1,229 +1,274 @@ + + import React, { useState, useEffect } from "react"; import { - StyleSheet, - Text, - View, - FlatList, - TouchableOpacity, - Modal, - PermissionsAndroid, - Platform, - NativeModules, + StyleSheet, + Text, + View, + FlatList, + TouchableOpacity, + Modal, + PermissionsAndroid, + Platform, + NativeModules, + Linking, + Alert, } from "react-native"; +import AppView from "../../components/AppView"; const { ContactsModule } = NativeModules; +const APP_URL = "https://play.google.com/store/apps/details?id=com.yourapp"; // replace with your real app url + const YourContacts = () => { - const [contacts, setContacts] = useState([]); - const [selectedContact, setSelectedContact] = useState(null); - const [modalVisible, setModalVisible] = useState(false); + const [contacts, setContacts] = useState([]); + const [selectedContact, setSelectedContact] = useState(null); + const [modalVisible, setModalVisible] = useState(false); - useEffect(() => { - handleFetchContacts(); - }, []); + useEffect(() => { + handleFetchContacts(); + }, []); - const handleFetchContacts = async () => { - try { - if (Platform.OS === "android") { - const granted = await PermissionsAndroid.request( - PermissionsAndroid.PERMISSIONS.READ_CONTACTS, - { - title: "Contacts Permission", - message: "This app would like to view your contacts.", - buttonPositive: "OK", - } - ); + const handleFetchContacts = async () => { + try { + if (Platform.OS === "android") { + const granted = await PermissionsAndroid.request( + PermissionsAndroid.PERMISSIONS.READ_CONTACTS, + { + title: "Contacts Permission", + message: "This app would like to view your contacts.", + buttonPositive: "OK", + } + ); - if (granted !== PermissionsAndroid.RESULTS.GRANTED) { - console.log("Contacts permission denied"); - return; + if (granted !== PermissionsAndroid.RESULTS.GRANTED) { + console.log("Contacts permission denied"); + return; + } + } + + const fetchedContacts = await ContactsModule.getContacts(); + setContacts(fetchedContacts); + } catch (error) { + console.error("Error fetching contacts:", error); } - } + }; - const fetchedContacts = await ContactsModule.getContacts(); - setContacts(fetchedContacts); - } catch (error) { - console.error("Error fetching contacts:", error); - } - }; + const APP_URL = "https://play.google.com/store/apps/details?id=com.yourapp"; // your app link + const WHATSAPP_URL = "https://play.google.com/store/apps/details?id=com.whatsapp"; // fallback store link - const handleSend = (contact: any) => { - setSelectedContact(contact); - setModalVisible(true); - }; + const handleSend = async (contact: any) => { + if (!contact) return; - const renderContact = ({ item }: { item: any }) => ( - - - - {item.name ? item.name.charAt(0).toUpperCase() : "?"} - - - - {item.name} - {item.phone} - - handleSend(item)} - > - Invite - - - ); + const message = `Hey ${contact.name}, check out this awesome app! Download here: ${APP_URL}`; - return ( - - Select Contact - index.toString()} - renderItem={renderContact} - /> + // direct send to contact if you want + const url = `whatsapp://send?phone=${contact.phone}&text=${encodeURIComponent( + message + )}`; - {/* Send Modal */} - setModalVisible(false)} - > - - - Send Invite - {selectedContact && ( - - Send invite to {selectedContact.name} ({selectedContact.phone})? - - )} - - setModalVisible(false)} - > - Cancel - - setModalVisible(false)} - > - Send - + try { + const supported = await Linking.canOpenURL("whatsapp://send"); + if (supported) { + // WhatsApp installed + await Linking.openURL(url); + } else { + // WhatsApp not installed → send user to Play Store/App Store + if (Platform.OS === "android") { + await Linking.openURL(WHATSAPP_URL); + } else if (Platform.OS === "ios") { + await Linking.openURL("itms-apps://apps.apple.com/app/whatsapp-messenger/id310633997"); + } + } + } catch (err) { + console.error("Error sending to WhatsApp:", err); + Alert.alert("Error", "Something went wrong while trying to open WhatsApp"); + } + + setModalVisible(false); + }; + + + const renderContact = ({ item }: { item: any }) => ( + + + + {item.name ? item.name.charAt(0).toUpperCase() : "?"} + - + + {item.name} + {item.phone} + + { + setSelectedContact(item); + setModalVisible(true); + }} + > + Invite + - - - ); + ); + + return ( + + + Select Contact + + + + index.toString()} + renderItem={renderContact} + /> + + {/* Send Modal */} + setModalVisible(false)} + > + + + Send Invite + {selectedContact && ( + + Send invite to {selectedContact.name} ({selectedContact.phone}) + + )} + + setModalVisible(false)} + > + Cancel + + handleSend(selectedContact)} + > + Send + + + + + + + ); }; + export default YourContacts; const styles = StyleSheet.create({ - container: { - flex: 1, - backgroundColor: "#fff", - paddingHorizontal: 10, - paddingTop: 20, - }, - header: { - fontSize: 20, - fontWeight: "bold", - marginBottom: 15, - }, - contactRow: { - flexDirection: "row", - alignItems: "center", - paddingVertical: 12, - borderBottomWidth: 0.5, - borderBottomColor: "#ddd", - }, - avatar: { - width: 45, - height: 45, - borderRadius: 25, - backgroundColor: "#25D366", - justifyContent: "center", - alignItems: "center", - marginRight: 12, - }, - avatarText: { - color: "#fff", - fontSize: 18, - fontWeight: "bold", - }, - contactInfo: { - flex: 1, - }, - contactName: { - fontSize: 16, - fontWeight: "600", - }, - contactPhone: { - fontSize: 13, - color: "gray", - }, - inviteButton: { - paddingHorizontal: 14, - paddingVertical: 6, - borderRadius: 8, - borderWidth: 1, - borderColor: "#25D366", - }, - inviteText: { - color: "#25D366", - fontWeight: "bold", - }, - modalOverlay: { - flex: 1, - backgroundColor: "rgba(0,0,0,0.5)", - justifyContent: "center", - alignItems: "center", - }, - modalContent: { - width: "80%", - backgroundColor: "#fff", - borderRadius: 10, - padding: 20, - alignItems: "center", - }, - modalTitle: { - fontSize: 18, - fontWeight: "bold", - marginBottom: 10, - }, - modalText: { - fontSize: 15, - marginBottom: 20, - textAlign: "center", - }, - modalActions: { - flexDirection: "row", - justifyContent: "space-between", - width: "100%", - }, - cancelButton: { - flex: 1, - marginRight: 10, - paddingVertical: 10, - borderRadius: 8, - backgroundColor: "#ddd", - alignItems: "center", - }, - cancelText: { - fontWeight: "bold", - color: "#333", - }, - sendButton: { - flex: 1, - marginLeft: 10, - paddingVertical: 10, - borderRadius: 8, - backgroundColor: "#25D366", - alignItems: "center", - }, - sendText: { - fontWeight: "bold", - color: "#fff", - }, + container: { + flex: 1, + backgroundColor: "#fff", + paddingHorizontal: 10, + paddingTop: 20, + }, + header: { + fontSize: 20, + fontWeight: "bold", + marginBottom: 15, + }, + contactRow: { + flexDirection: "row", + alignItems: "center", + paddingVertical: 12, + borderBottomWidth: 0.5, + borderBottomColor: "#ddd", + }, + avatar: { + width: 45, + height: 45, + borderRadius: 25, + backgroundColor: "#25D366", + justifyContent: "center", + alignItems: "center", + marginRight: 12, + }, + avatarText: { + color: "#fff", + fontSize: 18, + fontWeight: "bold", + }, + contactInfo: { + flex: 1, + }, + contactName: { + fontSize: 16, + fontWeight: "600", + }, + contactPhone: { + fontSize: 13, + color: "gray", + }, + inviteButton: { + paddingHorizontal: 14, + paddingVertical: 6, + borderRadius: 8, + borderWidth: 1, + borderColor: "#25D366", + }, + inviteText: { + color: "#25D366", + fontWeight: "bold", + }, + modalOverlay: { + flex: 1, + backgroundColor: "rgba(0,0,0,0.5)", + justifyContent: "center", + alignItems: "center", + }, + modalContent: { + width: "80%", + backgroundColor: "#fff", + borderRadius: 10, + padding: 20, + alignItems: "center", + }, + modalTitle: { + fontSize: 18, + fontWeight: "bold", + marginBottom: 10, + }, + modalText: { + fontSize: 15, + marginBottom: 20, + textAlign: "center", + }, + modalActions: { + flexDirection: "row", + justifyContent: "space-between", + width: "100%", + }, + cancelButton: { + flex: 1, + marginRight: 10, + paddingVertical: 10, + borderRadius: 8, + backgroundColor: "#ddd", + alignItems: "center", + }, + cancelText: { + fontWeight: "bold", + color: "#333", + }, + sendButton: { + flex: 1, + marginLeft: 10, + paddingVertical: 10, + borderRadius: 8, + backgroundColor: "#25D366", + alignItems: "center", + }, + sendText: { + fontWeight: "bold", + color: "#fff", + }, }); diff --git a/src/screens/profile/Profile.tsx b/src/screens/profile/Profile.tsx index 87b24db..5a4bbd8 100644 --- a/src/screens/profile/Profile.tsx +++ b/src/screens/profile/Profile.tsx @@ -332,11 +332,28 @@ const Profile = () => { {/* Profile Card */} {/* Profile Image Section */} - { - statusData?.role && statusData?.organizerStatus ? - Your Role: {statusData.role} | Organizer Status: {statusData.organizerStatus} - : - } + { + statusData?.role === "USER" && statusData?.organizerStatus !== "NOT_APPLIED" ? ( + + Your Role: {statusData.role} | Organizer Status: {statusData.organizerStatus} + + ) : ( + statusData?.role !== "ORGANIZER" && ( + + ) + ) + } + = ({ 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,18 +35,17 @@ const SwitchNavigator: React.FC = ({ role, status }) => { return ( - {!isEnabled && role !== "USER" + {!isEnabled && role !== "USER" ? "Become an Organizer" : `Request Organizer Role ${status}`} - {role !== "USER" ? ( - ) : } + ); };