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: "*/*" } }
|
{ headers: { "Content-Type": "application/json", Accept: "*/*" } }
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log("📩 OTP Resent:", res.data);
|
console.log("📩 OTP Resent:", res);
|
||||||
setCode(Array(CELL_COUNT).fill(""));
|
setCode(Array(CELL_COUNT).fill(""));
|
||||||
inputs.current[0]?.focus();
|
inputs.current[0]?.focus();
|
||||||
ToastAndroid.show("OTP Sent", ToastAndroid.SHORT);
|
ToastAndroid.show("OTP Sent", ToastAndroid.SHORT);
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import {
|
import {
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
@@ -9,10 +11,15 @@ import {
|
|||||||
PermissionsAndroid,
|
PermissionsAndroid,
|
||||||
Platform,
|
Platform,
|
||||||
NativeModules,
|
NativeModules,
|
||||||
|
Linking,
|
||||||
|
Alert,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
|
import AppView from "../../components/AppView";
|
||||||
|
|
||||||
const { ContactsModule } = NativeModules;
|
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 YourContacts = () => {
|
||||||
const [contacts, setContacts] = useState<any[]>([]);
|
const [contacts, setContacts] = useState<any[]>([]);
|
||||||
const [selectedContact, setSelectedContact] = useState<any>(null);
|
const [selectedContact, setSelectedContact] = useState<any>(null);
|
||||||
@@ -47,11 +54,41 @@ const YourContacts = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSend = (contact: any) => {
|
const APP_URL = "https://play.google.com/store/apps/details?id=com.yourapp"; // your app link
|
||||||
setSelectedContact(contact);
|
const WHATSAPP_URL = "https://play.google.com/store/apps/details?id=com.whatsapp"; // fallback store link
|
||||||
setModalVisible(true);
|
|
||||||
|
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 }) => (
|
const renderContact = ({ item }: { item: any }) => (
|
||||||
<View style={styles.contactRow}>
|
<View style={styles.contactRow}>
|
||||||
<View style={styles.avatar}>
|
<View style={styles.avatar}>
|
||||||
@@ -65,7 +102,10 @@ const YourContacts = () => {
|
|||||||
</View>
|
</View>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={styles.inviteButton}
|
style={styles.inviteButton}
|
||||||
onPress={() => handleSend(item)}
|
onPress={() => {
|
||||||
|
setSelectedContact(item);
|
||||||
|
setModalVisible(true);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Text style={styles.inviteText}>Invite</Text>
|
<Text style={styles.inviteText}>Invite</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
@@ -73,8 +113,12 @@ const YourContacts = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<AppView>
|
||||||
|
<View>
|
||||||
<Text style={styles.header}>Select Contact</Text>
|
<Text style={styles.header}>Select Contact</Text>
|
||||||
|
|
||||||
|
</View>
|
||||||
|
|
||||||
<FlatList
|
<FlatList
|
||||||
data={contacts}
|
data={contacts}
|
||||||
keyExtractor={(item, index) => index.toString()}
|
keyExtractor={(item, index) => index.toString()}
|
||||||
@@ -93,7 +137,7 @@ const YourContacts = () => {
|
|||||||
<Text style={styles.modalTitle}>Send Invite</Text>
|
<Text style={styles.modalTitle}>Send Invite</Text>
|
||||||
{selectedContact && (
|
{selectedContact && (
|
||||||
<Text style={styles.modalText}>
|
<Text style={styles.modalText}>
|
||||||
Send invite to {selectedContact.name} ({selectedContact.phone})?
|
Send invite to {selectedContact.name} ({selectedContact.phone})
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
<View style={styles.modalActions}>
|
<View style={styles.modalActions}>
|
||||||
@@ -105,7 +149,7 @@ const YourContacts = () => {
|
|||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={styles.sendButton}
|
style={styles.sendButton}
|
||||||
onPress={() => setModalVisible(false)}
|
onPress={() => handleSend(selectedContact)}
|
||||||
>
|
>
|
||||||
<Text style={styles.sendText}>Send</Text>
|
<Text style={styles.sendText}>Send</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
@@ -113,10 +157,11 @@ const YourContacts = () => {
|
|||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</Modal>
|
</Modal>
|
||||||
</View>
|
</AppView>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default YourContacts;
|
export default YourContacts;
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
|
|||||||
@@ -333,10 +333,27 @@ const Profile = () => {
|
|||||||
<View style={styles.profileCard}>
|
<View style={styles.profileCard}>
|
||||||
{/* Profile Image Section */}
|
{/* Profile Image Section */}
|
||||||
{
|
{
|
||||||
statusData?.role && 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>
|
<Text
|
||||||
:
|
style={{
|
||||||
<SwitchNavigator role={statusData?.role || ''} status={statusData?.organizerStatus || ''} />}
|
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.profileImageSection}>
|
||||||
<View style={styles.avatarContainer}>
|
<View style={styles.avatarContainer}>
|
||||||
<Image
|
<Image
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import React, { useState } from "react";
|
|||||||
import { View, Text, StyleSheet, Switch } from "react-native";
|
import { View, Text, StyleSheet, Switch } from "react-native";
|
||||||
import { useNavigation } from "@react-navigation/native";
|
import { useNavigation } from "@react-navigation/native";
|
||||||
import type { NativeStackNavigationProp } from "@react-navigation/native-stack";
|
import type { NativeStackNavigationProp } from "@react-navigation/native-stack";
|
||||||
import colors from "../../components/colors";
|
|
||||||
|
|
||||||
type RootStackParamList = {
|
type RootStackParamList = {
|
||||||
BecomeOrg: undefined;
|
BecomeOrg: undefined;
|
||||||
@@ -25,10 +24,6 @@ const SwitchNavigator: React.FC<SwitchNavigatorProps> = ({ role, status }) => {
|
|||||||
|
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
navigation.navigate("BecomeOrg"); // Navigate when ON
|
navigation.navigate("BecomeOrg"); // Navigate when ON
|
||||||
setTimeout(() => {
|
|
||||||
setIsEnabled(false);
|
|
||||||
}, 2000);
|
|
||||||
// Reset switch to OFF after navigation
|
|
||||||
} else {
|
} else {
|
||||||
navigation.navigate("Profile"); // Navigate when OFF
|
navigation.navigate("Profile"); // Navigate when OFF
|
||||||
}
|
}
|
||||||
@@ -44,14 +39,13 @@ const SwitchNavigator: React.FC<SwitchNavigatorProps> = ({ role, status }) => {
|
|||||||
? "Become an Organizer"
|
? "Become an Organizer"
|
||||||
: `Request Organizer Role ${status}`}
|
: `Request Organizer Role ${status}`}
|
||||||
</Text>
|
</Text>
|
||||||
{role !== "USER" ? (
|
|
||||||
<Switch
|
<Switch
|
||||||
trackColor={{ false: "#767577", true: colors.textLight }}
|
trackColor={{ false: "#767577", true: "#81b0ff" }}
|
||||||
thumbColor={isEnabled ? colors.pastelBlue : "#f4f3f4"}
|
thumbColor={isEnabled ? "#007AFF" : "#f4f3f4"}
|
||||||
ios_backgroundColor="#3e3e3e"
|
ios_backgroundColor="#3e3e3e"
|
||||||
onValueChange={toggleSwitch}
|
onValueChange={toggleSwitch}
|
||||||
value={isEnabled}
|
value={isEnabled}
|
||||||
/>) : <View> <Text> </Text></View>}
|
/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user