// Helper para mostrar N/A si el valor es nulo/vacío/inválido function displayValue(value) { if (value === null || value === undefined || value === '' || value === 'null') return 'N/A'; return value; } export function ClientItem(client, onView) { const fragment = document.createDocumentFragment(); const item = document.createElement('tr'); item.className = 'client-item'; const contactsCount = client.contacts ? client.contacts.length : 0; // Obtener texto de estado const getStatusText = (status) => { const statusMap = { '0': 'Inactivo', '1': 'Activo' }; return statusMap[status] || 'N/A'; }; const getStatusClass = (status) => { const classMap = { '0': 'status-inactive', '1': 'status-active' }; return classMap[status] || 'status-unknown'; }; // Obtener iniciales para el avatar const getInitials = () => { if (!client.name) return '?'; const words = client.name.split(' '); if (words.length >= 2) { return (words[0][0] + words[1][0]).toUpperCase(); } return client.name.substring(0, 2).toUpperCase(); }; // Generar color consistente basado en el nombre const getAvatarColor = () => { const colors = [ '#3b82f6', '#10b981', '#f59e0b', '#ef4444', '#8b5cf6', '#ec4899', '#06b6d4', '#84cc16', ]; let hash = 0; const name = client.name || ''; for (let i = 0; i < name.length; i++) { hash = name.charCodeAt(i) + ((hash << 5) - hash); } return colors[Math.abs(hash) % colors.length]; }; item.innerHTML = /*html*/`