import { Linking, Platform } from 'react-native'; export const handleEmailPress = (email?: string | null) => { if (!email) { console.warn('No email provided'); return; } Linking.openURL(`mailto:${email}`).catch(err => console.error('Error opening email:', err), ); }; export const handlePhonePress = (phoneNumber?: string | null) => { if (!phoneNumber) { console.warn('No phone number provided'); return; } const phoneUrl = Platform.OS === 'ios' ? `telprompt:${phoneNumber}` : `tel:${phoneNumber}`; Linking.openURL(phoneUrl).catch(err => console.error('Error opening phone:', err), ); }; export const handleWebsitePress = (website?: string | null) => { if (!website) { console.warn('No website provided'); return; } const url = website.startsWith('http') ? website : `https://${website}`; Linking.openURL(url).catch(err => console.error('Error opening website:', err), ); }; export const getInitials = (name?: string | null): string => { if (!name) return '?'; const nameParts = name.trim().split(' '); if (nameParts.length >= 2) { return (nameParts[0][0] + nameParts[nameParts.length - 1][0]).toUpperCase(); } return name.substring(0, 2).toUpperCase(); }; export const toRgba = (hex: string, alpha: number): string => { const h = hex.replace('#', ''); const r = parseInt(h.slice(0, 2), 16); const g = parseInt(h.slice(2, 4), 16); const b = parseInt(h.slice(4, 6), 16); return `rgba(${r},${g},${b},${alpha})`; }; export const formatDate = (raw: string): string => { if (!raw) return ''; const d = new Date(raw); return isNaN(d.getTime()) ? raw : d.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' }); };