/* global React, IconClose, IconExt, IconRefresh, IconBolt, IconMail, IconPhone, IconPin, IconClock, IconVideo, IconTag, IconGlobe, IconBuilding, IconCalendar, SourceBadge */ // Ficha del cliente que agendó (Calendly): contacto, cita, formulario, // atribución (UTM), notas internas e historial. function Drawer({ c, onClose, stages, closers, onChangeStage, onChangeCloser, onAddNote, onEditNote, onDeleteNote, onUpdateSale }) { const [tab, setTab] = React.useState("detalle"); const { CALL_STATUS, SOURCES } = window.REVOLVR_DATA; const stage = stages.find((s) => s.id === c.stage); const closer = closers.find((x) => x.id === c.closerId); const st = CALL_STATUS[c.status] || {}; const src = SOURCES[c.utm.source] || { label: c.utm.source, color: "#94a3b8" }; const [noteDraft, setNoteDraft] = React.useState(""); const [editingNote, setEditingNote] = React.useState(null); const [editDraft, setEditDraft] = React.useState(""); const initials = c.name.split(" ").map((s) => s[0]).slice(0, 2).join(""); const dateLong = c.scheduledAt instanceof Date ? c.scheduledAt.toLocaleDateString("es-ES", { weekday: "long", day: "numeric", month: "long" }) + " · " + c.scheduledAt.toLocaleTimeString("es-ES", { hour: "2-digit", minute: "2-digit", hour12: false }) : ""; const addNote = () => { const t = noteDraft.trim(); if (!t) return; onAddNote(c.id, t); setNoteDraft(""); }; return ( <>
e.stopPropagation()}>
{initials}

{c.name}

{c.form.industria} · {c.location}
{st.label} {stage?.label}
{tab === "detalle" && } {tab === "notes" &&
{c.notes.length === 0 &&
Sin notas. Visibles solo para el equipo.
} {c.notes.map((n, i) =>
{n.who} · {n.ts}
{editingNote === i ?