added fetch contact from real device icon
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
|
||||
|
||||
import React, { useState, useEffect } from "react";
|
||||
import {
|
||||
StyleSheet,
|
||||
@@ -9,10 +11,15 @@ import {
|
||||
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<any[]>([]);
|
||||
const [selectedContact, setSelectedContact] = useState<any>(null);
|
||||
@@ -47,11 +54,41 @@ const YourContacts = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleSend = (contact: any) => {
|
||||
setSelectedContact(contact);
|
||||
setModalVisible(true);
|
||||
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 = async (contact: any) => {
|
||||
if (!contact) return;
|
||||
|
||||
const message = `Hey ${contact.name}, check out this awesome app! Download here: ${APP_URL}`;
|
||||
|
||||
// direct send to contact if you want
|
||||
const url = `whatsapp://send?phone=${contact.phone}&text=${encodeURIComponent(
|
||||
message
|
||||
)}`;
|
||||
|
||||
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 }) => (
|
||||
<View style={styles.contactRow}>
|
||||
<View style={styles.avatar}>
|
||||
@@ -65,7 +102,10 @@ const YourContacts = () => {
|
||||
</View>
|
||||
<TouchableOpacity
|
||||
style={styles.inviteButton}
|
||||
onPress={() => handleSend(item)}
|
||||
onPress={() => {
|
||||
setSelectedContact(item);
|
||||
setModalVisible(true);
|
||||
}}
|
||||
>
|
||||
<Text style={styles.inviteText}>Invite</Text>
|
||||
</TouchableOpacity>
|
||||
@@ -73,8 +113,12 @@ const YourContacts = () => {
|
||||
);
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<AppView>
|
||||
<View>
|
||||
<Text style={styles.header}>Select Contact</Text>
|
||||
|
||||
</View>
|
||||
|
||||
<FlatList
|
||||
data={contacts}
|
||||
keyExtractor={(item, index) => index.toString()}
|
||||
@@ -93,7 +137,7 @@ const YourContacts = () => {
|
||||
<Text style={styles.modalTitle}>Send Invite</Text>
|
||||
{selectedContact && (
|
||||
<Text style={styles.modalText}>
|
||||
Send invite to {selectedContact.name} ({selectedContact.phone})?
|
||||
Send invite to {selectedContact.name} ({selectedContact.phone})
|
||||
</Text>
|
||||
)}
|
||||
<View style={styles.modalActions}>
|
||||
@@ -105,7 +149,7 @@ const YourContacts = () => {
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity
|
||||
style={styles.sendButton}
|
||||
onPress={() => setModalVisible(false)}
|
||||
onPress={() => handleSend(selectedContact)}
|
||||
>
|
||||
<Text style={styles.sendText}>Send</Text>
|
||||
</TouchableOpacity>
|
||||
@@ -113,10 +157,11 @@ const YourContacts = () => {
|
||||
</View>
|
||||
</View>
|
||||
</Modal>
|
||||
</View>
|
||||
</AppView>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
export default YourContacts;
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
|
||||
@@ -333,10 +333,27 @@ const Profile = () => {
|
||||
<View style={styles.profileCard}>
|
||||
{/* Profile Image Section */}
|
||||
{
|
||||
statusData?.role && statusData?.organizerStatus ?
|
||||
<Text style={{ color: "#64748b", marginBottom: 16, textAlign: 'center', fontSize: 18 }}>Your Role: {statusData.role} | Organizer Status: {statusData.organizerStatus}</Text>
|
||||
:
|
||||
<SwitchNavigator role={statusData?.role || ''} status={statusData?.organizerStatus || ''} />}
|
||||
statusData?.role === "USER" && statusData?.organizerStatus !== "NOT_APPLIED" ? (
|
||||
<Text
|
||||
style={{
|
||||
color: "#64748b",
|
||||
marginBottom: 16,
|
||||
textAlign: "center",
|
||||
fontSize: 18,
|
||||
}}
|
||||
>
|
||||
Your Role: {statusData.role} | Organizer Status: {statusData.organizerStatus}
|
||||
</Text>
|
||||
) : (
|
||||
statusData?.role !== "ORGANIZER" && (
|
||||
<SwitchNavigator
|
||||
role={statusData?.role || ""}
|
||||
status={statusData?.organizerStatus || ""}
|
||||
/>
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
<View style={styles.profileImageSection}>
|
||||
<View style={styles.avatarContainer}>
|
||||
<Image
|
||||
|
||||
@@ -2,7 +2,6 @@ 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;
|
||||
@@ -25,10 +24,6 @@ const SwitchNavigator: React.FC<SwitchNavigatorProps> = ({ 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
|
||||
}
|
||||
@@ -44,14 +39,13 @@ const SwitchNavigator: React.FC<SwitchNavigatorProps> = ({ role, status }) => {
|
||||
? "Become an Organizer"
|
||||
: `Request Organizer Role ${status}`}
|
||||
</Text>
|
||||
{role !== "USER" ? (
|
||||
<Switch
|
||||
trackColor={{ false: "#767577", true: colors.textLight }}
|
||||
thumbColor={isEnabled ? colors.pastelBlue : "#f4f3f4"}
|
||||
trackColor={{ false: "#767577", true: "#81b0ff" }}
|
||||
thumbColor={isEnabled ? "#007AFF" : "#f4f3f4"}
|
||||
ios_backgroundColor="#3e3e3e"
|
||||
onValueChange={toggleSwitch}
|
||||
value={isEnabled}
|
||||
/>) : <View> <Text> </Text></View>}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user