import React from 'react'; import { View, Text, TouchableOpacity, Linking, Platform, } from 'react-native'; import Icon from 'react-native-vector-icons/Ionicons'; import { useTheme } from '@theme'; import { getStyles } from './leadItemCard.styles'; import { LeadItemCardProps } from './leadItemCard.props'; export const LeadItemCard: React.FC = ({ item, onPress, }) => { const { theme: colors } = useTheme(); const styles = getStyles(colors); // Get initials from name const getInitials = (name: string): string => { if (!name) return '?'; const nameParts = name.trim().split(' '); if (nameParts.length >= 2) { return (nameParts[0][0] + nameParts[1][0]).toUpperCase(); } return name.substring(0, 2).toUpperCase(); }; // Handle email press const handleEmailPress = () => { if (item.email) { Linking.openURL(`mailto:${item.email}`).catch(err => console.error('Error opening email:', err), ); } }; // Handle phone press const handlePhonePress = () => { if (item.phonenumber) { const phoneUrl = Platform.OS === 'ios' ? `telprompt:${item.phonenumber}` : `tel:${item.phonenumber}`; Linking.openURL(phoneUrl).catch(err => console.error('Error opening phone:', err), ); } }; return ( {/* Left side - Avatar/Initials */} {getInitials(item.name)} {/* Right side - Content */} {/* Name and Status Row */} {item.name || 'No Name'} {item.status_name || item.status || 'No Status'} {/* Email Row */} {item.email ? ( {item.email} ) : null} {/* Phone Row */} {item.phonenumber ? ( {item.phonenumber} ) : null} ); };