'use client'; import { useState } from 'react'; import Image from 'next/image'; interface ContactInfoProps { email: string; phone: string; } // Helper function to mask email function maskEmail(email: string): string { const [localPart, domain] = email.split('@'); if (!domain) return '********'; const maskedLocal = localPart.slice(0, 2) + '********'; return `${maskedLocal}@${domain}`; } // Helper function to mask phone function maskPhone(phone: string): string { if (!phone || phone.trim() === '') return '-'; if (phone.length <= 4) return '****' + phone; return phone.slice(0, -4).replace(/./g, '*') + phone.slice(-4); } export function ContactInfo({ email, phone }: ContactInfoProps) { const [showEmail, setShowEmail] = useState(false); const [showPhone, setShowPhone] = useState(false); return (
Email: {showEmail ? email : maskEmail(email)}
Ph.No: {showPhone ? phone : maskPhone(phone)}
); }