1import{u as $,j as e}from"./index-D0NFXJHP.js";import{r as i}from"./react-vendor-B-clOVnp.js";import{L as M}from"./TableSkeleton-DNsBd_Nn.js";import{c as q,a as S,S as g,R as T,d as F,e as H}from"./leadsPremium-CfUc1ptt.js";import{$ as Q,ay as J,R as K,J as P,X,U as W,M as G,b8 as _,l as V,aP as Y,Q as Z,u as ee,r as se}from"./icons-l1P0DWf7.js";const B=s=>s?new Date(s).toLocaleString("pt-BR",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):"â";function xe(){const{token:s}=$(),[a,l]=i.useState([]),[z,h]=i.useState({}),[A,R]=i.useState([]),[d,k]=i.useState(""),[n,I]=i.useState(""),[p,E]=i.useState(""),[j,x]=i.useState(!1),[b,y]=i.useState(""),[u,f]=i.useState(null),m=async()=>{x(!0),y("");try{const o={};d&&(o.status=d),n&&(o.assessorId=n),p.trim()&&(o.q=p.trim());const t=await F(s,o);l(t.leads||[]),h(t.totais||{})}catch(o){y(o.message)}finally{x(!1)}};return i.useEffect(()=>{s&&q(s).then(o=>R(o.assessores||[])).catch(()=>{})},[s]),i.useEffect(()=>{s&&m()},[s,d,n]),e.jsxs("div",{style:{padding:20,maxWidth:1200,margin:"0 auto"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:8},children:[e.jsx(Q,{size:26,color:"#7e22ce"}),e.jsx("h1",{style:{margin:0},children:"Leads Premium"})]}),e.jsxs("p",{style:{color:"#6b7280",fontSize:14,marginBottom:16},children:["Solicitações de plano personalizado vindas de empresas. Atribua um assessor para que ele trabalhe o lead no funil dele em ",e.jsx("code",{children:"/assessor/leads"}),"."]}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginBottom:12,alignItems:"center"},children:[e.jsx("button",{onClick:()=>k(""),style:O(d===""),children:"Todos"}),Object.entries(S).map(([o,t])=>{const r=g[o],c=d===o;return e.jsxs("button",{onClick:()=>k(c?"":o),style:{...O(c),background:c?r.cor:r.bg,color:c?"#fff":r.cor},children:[t," ",e.jsxs("span",{style:{opacity:.85,marginLeft:4},children:["(",z[o]||0,")"]})]},o)}),e.jsx("div",{style:{flex:1}}),e.jsxs("select",{value:n,onChange:o=>I(o.target.value),style:D,children:[e.jsx("option",{value:"",children:"Todos os assessores"}),e.jsx("option",{value:"sem",children:"â Sem assessor"}),A.map(o=>e.jsx("option",{value:o.assessorBubbleId,children:o.nome||o.email},o.assessorBubbleId))]}),e.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center"},children:[e.jsx(J,{size:14,color:"#9ca3af"}),e.jsx("input",{value:p,onChange:o=>E(o.target.value),onKeyDown:o=>o.key==="Enter"&&m(),placeholder:"empresa, contato, whatsappâ¦",style:D})]}),e.jsx("button",{onClick:m,title:"Recarregar",style:N,children:e.jsx(K,{size:14})})]}),b&&e.jsx("div",{style:{background:"#fee2e2",padding:10,borderRadius:6,marginBottom:12},children:b}),j&&a.length===0&&e.jsx(M,{itens:6}),!j&&a.length===0&&e.jsx("div",{style:{background:"#f9fafb",border:"1px dashed #d1d5db",borderRadius:12,padding:32,textAlign:"center",color:"#6b7280"},children:"Nenhum lead com os filtros atuais."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:a.map(o=>e.jsx(te,{lead:o,onAbrir:()=>f(o)},o._id))}),u&&e.jsx(oe,{lead:u,assessores:A,token:s,podeAtribuirAssessor:!0,onFechar:()=>f(null),onSalvo:()=>{f(null),m()}})]})}function te({lead:s,onAbrir:a}){const l=g[s.status]||g.novo;return e.jsxs("button",{onClick:a,style:{background:"#fff",border:"1px solid #e5e7eb",borderRadius:12,padding:14,textAlign:"left",cursor:"pointer",display:"flex",gap:12,alignItems:"center",borderLeft:`4px solid ${l.barra}`},children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[e.jsx(P,{size:14,color:"#6b7280"}),e.jsx("strong",{style:{fontSize:15},children:s.empresaNome||"(empresa sem nome)"}),e.jsx("span",{style:{fontSize:11,padding:"2px 8px",borderRadius:999,background:l.bg,color:l.cor,fontWeight:600},children:S[s.status]}),s.assessorNome?e.jsxs("span",{style:{fontSize:11,color:"#0369a1",display:"inline-flex",alignItems:"center",gap:4},children:[e.jsx(W,{size:11})," ",s.assessorNome]}):e.jsxs("span",{style:{fontSize:11,color:"#dc2626",display:"inline-flex",alignItems:"center",gap:4},children:[e.jsx(Z,{size:11})," Sem assessor"]})]}),e.jsxs("div",{style:{display:"flex",gap:14,fontSize:12,color:"#6b7280",marginTop:6,flexWrap:"wrap"},children:[e.jsxs("span",{children:[e.jsx(W,{size:11,style:{verticalAlign:"middle"}})," ",s.contratanteNome||"â"]}),s.whatsapp&&e.jsxs("span",{children:[e.jsx(_,{size:11,style:{verticalAlign:"middle"}})," ",s.whatsapp]}),e.jsxs("span",{children:[e.jsx(ee,{size:11,style:{verticalAlign:"middle"}})," ",B(s.criadoEm)]})]})]}),e.jsx(se,{size:18,color:"#cbd5e1"})]})}function oe({lead:s,assessores:a=[],token:l,podeAtribuirAssessor:z,onFechar:h,onSalvo:A,salvarFn:R}){const[d,k]=i.useState(s.status),[n,I]=i.useState(s.assessorId||""),[p,E]=i.useState(""),[j,x]=i.useState(!1),[b,y]=i.useState(""),u=s.respostas||{},f=g[s.status]||g.novo,m=R||(t=>H(l,s._id,t)),o=async()=>{x(!0),y("");try{const t={};if(d!==s.status&&(t.status=d),z&&(n||"")!==(s.assessorId||"")&&(t.assessorId=n,n)){const r=a.find(c=>c.assessorBubbleId===n);t.assessorNome=r?.nome||""}if(p.trim()&&(t.anotacao=p.trim()),Object.keys(t).length===0){x(!1),h();return}await m(t),A()}catch(t){y(t.message)}finally{x(!1)}};return e.jsx("div",{style:ie,children:e.jsxs("div",{style:ae,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:16,gap:10},children:[e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(P,{size:18,color:"#7e22ce"}),e.jsx("h3",{style:{margin:0},children:s.empresaNome||"(empresa sem nome)"}),e.jsx("span",{style:{fontSize:11,padding:"2px 8px",borderRadius:999,background:f.bg,color:f.cor,fontWeight:600},children:S[s.status]})]}),e.jsxs("div",{style:{fontSize:12,color:"#6b7280",marginTop:4},children:["Recebido em ",B(s.criadoEm)]})]}),e.jsx("button",{onClick:h,style:N,children:e.jsx(X,{size:16})})]}),b&&e.jsx("div",{style:{background:"#fee2e2",padding:10,borderRadius:6,marginBottom:12},children:b}),e.jsxs(v,{titulo:"Dados de contato",children:[e.jsx(w,{icone:e.jsx(W,{size:13}),label:"Quem solicitou",valor:s.contratanteNome||"â"}),e.jsx(w,{icone:e.jsx(G,{size:13}),label:"E-mail",valor:s.contratanteEmail||"â"}),e.jsx(w,{icone:e.jsx(_,{size:13}),label:`WhatsApp${s.whatsappEhAlternativo?" (alternativo)":""}`,valor:s.whatsapp||"â"})]}),e.jsx(v,{titulo:"Respostas do formulário",children:Object.keys(T).map(t=>{const r=u[t],c=T[t],U=r?c.opcoes[r]||r:"â";return e.jsxs("div",{style:{marginBottom:8},children:[e.jsx("div",{style:{fontSize:12,color:"#6b7280"},children:c.pergunta}),e.jsx("div",{style:{fontSize:14,color:"#111827",fontWeight:500},children:U}),t==="maiorDesafio"&&r==="outro"&&u.maiorDesafioOutro&&e.jsxs("div",{style:{fontSize:13,color:"#374151",fontStyle:"italic",marginTop:2},children:['"',u.maiorDesafioOutro,'"']})]},t)})}),e.jsxs(v,{titulo:"Atualizar",children:[z&&e.jsx(C,{label:"Assessor responsável",children:e.jsxs("select",{value:n,onChange:t=>I(t.target.value),style:L,children:[e.jsx("option",{value:"",children:"â Sem assessor"}),a.map(t=>e.jsx("option",{value:t.assessorBubbleId,children:t.nome||t.email},t.assessorBubbleId))]})}),e.jsx(C,{label:"Status",children:e.jsx("select",{value:d,onChange:t=>k(t.target.value),style:L,children:Object.entries(S).map(([t,r])=>e.jsx("option",{value:t,children:r},t))})}),e.jsx(C,{label:"Adicionar anotação",children:e.jsx("textarea",{value:p,onChange:t=>E(t.target.value),rows:3,placeholder:"Ex.: liguei hoje, retorna na sextaâ¦",style:{...L,fontFamily:"inherit",resize:"vertical"}})})]}),s.anotacoes?.length>0&&e.jsx(v,{titulo:`Histórico de anotações (${s.anotacoes.length})`,children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8,maxHeight:200,overflow:"auto"},children:[...s.anotacoes].reverse().map(t=>e.jsxs("div",{style:{background:"#f9fafb",borderLeft:"3px solid #7e22ce",padding:10,borderRadius:6,fontSize:13},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:"#6b7280",fontSize:11,marginBottom:4},children:[e.jsx(V,{size:11}),e.jsx("strong",{style:{color:"#374151"},children:t.autorNome||"â"}),e.jsxs("span",{children:["· ",t.autorPerfil]}),e.jsxs("span",{children:["· ",B(t.criadoEm)]})]}),e.jsx("div",{style:{color:"#111827",whiteSpace:"pre-wrap"},children:t.texto})]},t._id||t.criadoEm))})}),s.historicoStatus?.length>0&&e.jsx(v,{titulo:"Linha do tempo do status",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,fontSize:12,color:"#6b7280"},children:s.historicoStatus.map((t,r)=>e.jsxs("div",{children:[e.jsx("strong",{style:{color:g[t.status]?.cor||"#374151"},children:S[t.status]||t.status})," · ",B(t.em),t.porNome&&` · por ${t.porNome}`]},r))})}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:16},children:[e.jsxs("button",{onClick:o,disabled:j,style:re,children:[e.jsx(Y,{size:14})," ",j?"Salvandoâ¦":"Salvar alterações"]}),e.jsx("div",{style:{flex:1}}),e.jsx("button",{onClick:h,style:N,children:"Fechar"})]})]})})}function v({titulo:s,children:a}){return e.jsxs("div",{style:{marginBottom:16,paddingBottom:12,borderBottom:"1px solid #f3f4f6"},children:[e.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#6b7280",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:8},children:s}),a]})}function w({icone:s,label:a,valor:l}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[e.jsx("span",{style:{color:"#9ca3af"},children:s}),e.jsxs("span",{style:{fontSize:12,color:"#6b7280",minWidth:100},children:[a,":"]}),e.jsx("span",{style:{fontSize:13,color:"#111827",fontWeight:500},children:l})]})}function C({label:s,children:a}){return e.jsxs("div",{style:{marginBottom:10},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:"#374151",marginBottom:4,fontWeight:500},children:s}),a]})}const ie={position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",zIndex:100,display:"flex",alignItems:"center",justifyContent:"center",padding:16},ae={background:"#fff",borderRadius:12,padding:20,maxWidth:720,width:"100%",maxHeight:"92vh",overflow:"auto"},L={width:"100%",padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:6,fontSize:14,boxSizing:"border-box",background:"#fff"},D={padding:"6px 10px",border:"1px solid #d1d5db",borderRadius:6,fontSize:13,background:"#fff"},re={display:"inline-flex",alignItems:"center",gap:6,background:"#7e22ce",color:"#fff",border:"none",padding:"8px 14px",borderRadius:8,fontSize:13,fontWeight:600,cursor:"pointer"},N={display:"inline-flex",alignItems:"center",gap:6,background:"#fff",color:"#374151",border:"1px solid #d1d5db",padding:"6px 10px",borderRadius:8,fontSize:13,cursor:"pointer"},O=s=>({padding:"6px 12px",borderRadius:8,border:"none",cursor:"pointer",background:s?"#7e22ce":"#f3f4f6",color:s?"#fff":"#374151",fontWeight:600,fontSize:12});export{oe as ModalLead,xe as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.