// ============================================================ // JuFlow — Client Detail (5-tab full profile) // ============================================================ const { useState: useStCD, useMemo: useMemoCD } = React; const UCD = window.JFUtils; const ClientDetail = ({ client, appointments, onClose, onNewAppt, addToast }) => { const [tab, setTab] = useStCD('dados'); const [editMode, setEditMode] = useStCD(false); const [formData, setFormData] = useStCD({ ...client }); if (!client) return null; const setF = (k, v) => setFormData(f => ({ ...f, [k]: v })); const setAnamnese = (k, v) => setFormData(f => ({ ...f, anamnese: { ...f.anamnese, [k]: v } })); const clientAppts = useMemoCD(() => appointments .filter(a => a.clientId === client.id) .sort((a, b) => new Date(b.datetime) - new Date(a.datetime)) , [appointments, client.id]); const completedAppts = clientAppts.filter(a => a.status === 'completed'); const clientPkgs = window.JF.CLIENT_PACKAGES.filter(p => p.clientId === client.id); const totalSpent = completedAppts.reduce((s, a) => s + a.price, 0); const avgTicket = completedAppts.length ? totalSpent / completedAppts.length : 0; // ── TAB: Dados Pessoais ───────────────────────────────── const TabDados = () => (
{/* Profile header */}

{client.name}

{client.tags.map(tag => )} {client.status === 'inactive' && }
{[ { label:'Sessões', value: completedAppts.length, icon:'Calendar' }, { label:'Total gasto', value: UCD.formatCurrency(totalSpent), icon:'DollarSign' }, { label:'Ticket médio', value: UCD.formatCurrency(avgTicket), icon:'TrendingUp' }, ].map(stat => (
{stat.value}
{stat.label}
))}
{/* Personal data grid */}

Dados Pessoais

{[ { label:'Nome completo', key:'name', icon:'User' }, { label:'Telefone/WhatsApp', key:'phone', icon:'Phone' }, { label:'E-mail', key:'email', icon:'Mail' }, { label:'CPF', key:'cpf', icon:'CreditCard' }, { label:'Data de nascimento', key:'birthdate', icon:'Cake', format:v => v ? `${UCD.formatDate(v)} (${UCD.age(v)} anos)` : '—' }, { label:'Endereço', key:'address', icon:'MapPin', span:2 }, ].map(field => (
{field.label}
{editMode ? setF(field.key, v)} icon={field.icon} /> :
{field.format ? field.format(client[field.key]) : (client[field.key] || '—')}
}
))}
{/* Tags */}

Tags

{client.tags.map(tag => )} {['VIP','Aniversariante','Inadimplente','Regular'].filter(t => !client.tags.includes(t)).map(tag => ( ))}
{/* Notes */}

Observações

{editMode ?