PageSourceSearch

https://cbnamazonia.com/assets/AdsAccounts-B2SqMZsr.js

js cbnamazonia.com collected 2026-10-03 20:27:34 UTC 19,981 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-editor-BX0sR0z-.js";import{r}from"./vendor-react-BPk9u-w4.js";import{h as v,l as k,m as C,d as L,u as R}from"./index-s_BTi5XF.js";import{u as $}from"./useAccounts-DxENSI2p.js";import{A as B}from"./AccountModal-If8r4rKr.js";import{A as O}from"./index-T0bE9RkD.js";import{$ as A,Y as S,X as M,J as E,v as F,U as I,ae as T,cU as U,ab as W,y as q,u as J,i as G,L as Q,b0 as V,a as H}from"./vendor-icons-XRoHuOlC.js";import"./vendor-charts-Cf-ruFca.js";import"./vendor-ui-utils-Bbg69IUi.js";import"./vendor-graph-Df3mHyA7.js";import"./vendor-supabase-UBwEW4nm.js";import"./vendor-sonner-DPZ7yCFm.js";import"./vendor-helmet-C74EPpLp.js";import"./useAdAuditLogs-BJvMVNgf.js";import"./cnpj-C_aMig2Z.js";import"./cnpjLookup-ByxJCp2a.js";import"./useCnpjAutofill-CJSD-kLv.js";const X=({isOpen:c,onClose:g,account:a})=>{const[n,N]=r.useState([]),[f,x]=r.useState([]),[y,o]=r.useState(!1),[j,p]=r.useState(!1),[l,d]=r.useState({name:"",email:"",phone:"",role:""});r.useEffect(()=>{c&&a.id&&m()},[c,a.id]);const m=async()=>{o(!0);try{const[t,i]=await Promise.all([v.from("ad_deals").select("*").eq("account_id",a.id),v.from("ad_contacts").select("*").eq("account_id",a.id)]);N(t.data||[]),x(i.data||[])}catch(t){k.error(t)}finally{o(!1)}},h=async()=>{if(l.name)try{const{error:t}=await v.from("ad_contacts").upsert([{account_id:a.id,...l}],{onConflict:"email,account_id"});if(t)throw t;p(!1),d({name:"",email:"",phone:"",role:""}),m()}catch(t){k.error(t)}};return e.jsx(O,{children:c&&e.jsxs(e.Fragment,{children:[e.jsx(C.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},onClick:g,className:"fixed inset-0 z-[1100] bg-slate-900/40 backdrop-blur-sm"}),e.jsxs(C.aside,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",damping:25,stiffness:200},className:"fixed top-0 right-0 bottom-0 w-full max-w-lg bg-white z-[1200] shadow-2xl flex flex-col",children:[e.jsxs("div",{className:"p-8 border-b border-slate-100 flex items-center justify-between bg-slate-50/50",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:`p-4 rounded-2xl ${a.type==="agency"?"bg-purple-600 shadow-purple-100":"bg-blue-600 shadow-blue-100"} text-white shadow-lg`,children:a.type==="agency"?e.jsx(A,{size:28}):e.jsx(S,{size:28})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-black text-slate-800 tracking-tight",children:a.name}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("span",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest",children:a.document||a.cnpj||"Sem Documento"}),e.jsx("span",{className:"w-1 h-1 rounded-full bg-slate-300"}),e.jsxs("span",{className:"text-[10px] font-black text-emerald-600 uppercase tracking-widest",children:["Conta ",a.status]})]})]})]}),e.jsx("button",{onClick:g,className:"p-3 hover:bg-slate-200 rounded-2xl transition-colors text-slate-400",children:e.jsx(M,{size:24})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-8 space-y-8",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-6 bg-slate-50 rounded-3xl border border-slate-100",children:[e.jsx("div",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest mb-1",children:"Total em Pipeline"}),e.jsx("div",{className:"text-xl font-black text-slate-800",children:new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL"}).format(n.reduce((t,i)=>t+(i.value||0),0))})]}),e.jsxs("div",{className:"p-6 bg-slate-50 rounded-3xl border border-slate-100",children:[e.jsx("div",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest mb-1",children:"Negócios Ativos"}),e.jsx("div",{className:"text-xl font-black text-slate-800",children:n.length})]})]}),e.jsxs("div",{className:`p-6 rounded-[2rem] border transition-all ${a.lgpd_consent?"bg-emerald-50 border-emerald-100":"bg-amber-50 border-amber-100"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-xl ${a.lgpd_consent?"bg-emerald-500":"bg-amber-500"} text-white`,children:e.jsx(E,{size:20})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-black uppercase tracking-widest opacity-60",children:"Status de Privacidade"}),e.jsx("div",{className:"font-black text-slate-800 tracking-tight",children:a.lgpd_consent?"Consentimento LGPD Ativo":"Consentimento Pendente"})]})]}),e.jsx("button",{onClick:async()=>{const t=!a.lgpd_consent,{error:i}=await v.from("ad_accounts").update({lgpd_consent:t,consent_date:t?new Date().toISOString():null}).eq("id",a.id);i||window.location.reload()},className:`px-4 py-2 rounded-xl text-[10px] font-black uppercase tracking-widest transition-all ${a.lgpd_consent?"bg-white text-emerald-600 border border-emerald-200":"bg-amber-600 text-white shadow-lg shadow-amber-200"}`,children:a.lgpd_consent?"Revogar":"Autorizar"})]}),a.consent_date&&e.jsxs("div",{className:"mt-3 text-[9px] font-bold text-slate-400 uppercase tracking-widest italic flex items-center gap-1",children:[e.jsx(F,{size:10})," Registrado em"," ",new Date(a.consent_date).toLocaleString()]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-xs font-black text-slate-800 uppercase tracking-widest flex items-center gap-2",children:[e.jsx(I,{size:14,className:"text-blue-600"}),"Decisores & Contatos"]}),!j&&e.jsx("button",{onClick:()=>p(!0),className:"text-[10px] font-black text-blue-600 uppercase tracking-widest hover:underline",children:"+ Adicionar"})]}),j&&e.jsxs("div",{className:"mb-6 p-6 bg-blue-50/50 rounded-[2rem] border border-blue-100 space-y-4 animate-in fade-in slide-in-from-top-2 duration-300",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx("input",{type:"text",placeholder:"Nome completo",className:"col-span-2 w-full px-4 py-3 bg-white border border-blue-200 rounded-2xl text-xs focus:outline-none focus:border-blue-500",value:l.name,onChange:t=>d({...l,name:t.target.value})}),e.jsx("input",{type:"email",placeholder:"Email corporativo",className:"w-full px-4 py-3 bg-white border border-blue-200 rounded-2xl text-xs focus:outline-none focus:border-blue-500",value:l.email,onChange:t=>d({...l,email:t.target.value})}),e.jsx("input",{type:"text",placeholder:"WhatsApp (ex: 11999999999)",className:"w-full px-4 py-3 bg-white border border-blue-200 rounded-2xl text-xs focus:outline-none focus:border-blue-500",value:l.phone,onChange:t=>d({...l,phone:t.target.value})}),e.jsx("input",{type:"text",placeholder:"Cargo / Role",className:"col-span-2 w-full px-4 py-3 bg-white border border-blue-200 rounded-2xl text-xs focus:outline-none focus:border-blue-500",value:l.role,onChange:t=>d({...l,role:t.target.value})})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:h,className:"flex-1 bg-blue-600 text-white rounded-2xl py-3 text-[10px] font-black uppercase tracking-widest hover:bg-blue-700 shadow-lg shadow-blue-100 transition-all",children:"Salvar Contato"}),e.jsx("button",{onClick:()=>p(!1),className:"px-6 py-3 bg-white border border-slate-200 rounded-2xl text-[10px] font-black uppercase tracking-widest text-slate-400 hover:bg-slate-50 transition-all",children:"Cancelar"})]})]}),e.jsxs("div",{className:"space-y-4",children:[f.map(t=>e.jsxs("div",{className:"p-5 bg-white border border-slate-100 rounded-[1.5rem] flex items-center justify-between group hover:border-blue-200 hover:shadow-xl hover:shadow-slate-100 transition-all font-sans",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-slate-50 flex items-center justify-center text-slate-400 text-xs font-black border border-slate-100 group-hover:bg-blue-50 group-hover:text-blue-600 group-hover:border-blue-100 transition-all",children:t.name.substring(0,2).toUpperCase()}),e.jsxs("div",{children:[e.jsx("div",{className:"font-black text-slate-800 text-sm tracking-tight",children:t.name}),e.jsx("div",{className:"text-[10px] text-slate-400 font-bold uppercase tracking-widest mt-0.5",children:t.role||t.job_title||"Ponto de Contato"})]})]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[t.email&&e.jsx("button",{onClick:()=>window.open(`mailto:${t.email}`),className:"p-3 hover:bg-slate-50 rounded-xl text-slate-400 hover:text-blue-600",title:t.email,children:e.jsx(T,{size:18})}),t.phone&&e.jsx("button",{onClick:()=>window.open(`https://wa.me/55${t.phone.replace(/\D/g,"")}`),className:"p-3 hover:bg-emerald-50 rounded-xl text-slate-400 hover:text-emerald-600",title:"Chamar no WhatsApp",children:e.jsx("svg",{className:"w-[18px] h-[18px]",viewBox:"0 0 24 24",fill:"
1currentColor",children:e.jsx("path",{d:"M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.414 0 .018 5.393 0 12.03a11.782 11.782 0 001.592 5.96L0 24l6.117-1.604a11.77 11.77 0 005.925 1.597h.005c6.634 0 12.032-5.393 12.035-12.031a11.761 11.761 0 00-3.504-8.495z"})})}),e.jsx("button",{className:"p-3 hover:bg-slate-50 rounded-xl text-slate-400 hover:text-blue-600",children:e.jsx(U,{size:18})})]})]},t.id)),f.length===0&&e.jsx("div",{className:"text-center py-12 border-2 border-dashed border-slate-100 rounded-[2rem] text-slate-400 text-xs font-black uppercase tracking-widest bg-slate-50/30",children:"Nenhum contato salvo"})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-xs font-black text-slate-800 uppercase tracking-widest flex items-center gap-2",children:[e.jsx(W,{size:14,className:"text-indigo-600"}),"Histórico de Propostas"]}),e.jsx("button",{className:"text-[10px] font-black text-indigo-600 uppercase tracking-widest hover:underline",children:"Ver Funil"})]}),e.jsxs("div",{className:"space-y-4",children:[n.map(t=>e.jsxs("div",{className:"p-6 bg-white border border-slate-100 rounded-[2rem] group hover:border-indigo-200 transition-all hover:shadow-xl hover:shadow-indigo-50/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("div",{className:"font-black text-slate-800 text-sm tracking-tight group-hover:text-indigo-600 transition-colors",children:t.title}),e.jsx("div",{className:"text-sm font-black text-emerald-600",children:new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL"}).format(t.value)})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`text-[9px] font-black px-2.5 py-1 rounded-full uppercase tracking-widest ${t.stage==="won"?"bg-emerald-50 text-emerald-600":t.stage==="lost"?"bg-rose-50 text-rose-600":"bg-slate-100 text-slate-500"}`,children:t.stage}),e.jsx("span",{className:"text-[9px] font-bold text-slate-300 uppercase tracking-widest",children:new Date(t.created_at).toLocaleDateString()})]})]},t.id)),n.length===0&&e.jsx("div",{className:"text-center py-12 border-2 border-dashed border-slate-100 rounded-[2rem] text-slate-400 text-xs font-black uppercase tracking-widest bg-slate-50/30",children:"Nenhuma proposta vinculada"})]})]})]}),e.jsxs("div",{className:"p-8 border-t border-slate-100 bg-slate-50/30 flex items-center gap-4",children:[e.jsx("button",{className:"flex-1 bg-white border border-slate-200 hover:bg-slate-50 text-slate-700 px-6 py-4 rounded-[1.5rem] font-black text-xs uppercase tracking-widest transition-all shadow-sm",children:"Perfil Completo"}),e.jsx("button",{className:"flex-1 bg-blue-600 hover:bg-blue-700 text-white px-6 py-4 rounded-[1.5rem] font-black text-xs uppercase tracking-widest transition-all shadow-xl shadow-blue-100",children:"Nova Oportunidade"})]})]})]})})},he=({type:c})=>{const{currentPortal:g}=L(),{profile:a}=R(),{accounts:n,loading:N,upsertAccount:f}=$(g.id,c,a==null?void 0:a.organization_id),[x,y]=r.useState(""),[o,j]=r.useState("all"),[p,l]=r.useState(!1),[d,m]=r.useState(!1),[h,t]=r.useState(),i=r.useMemo(()=>{const s=n.filter(b=>b.status==="active").length,u=n.filter(b=>b.status!=="active").length;return{active:s,prospect:u,total:n.length}},[n]),w=r.useMemo(()=>n.filter(s=>{const u=s.name.toLowerCase().includes(x.toLowerCase())||(s.document||"").includes(x),b=o==="all"||o==="active"&&s.status==="active"||o==="prospect"&&s.status!=="active";return u&&b}),[n,x,o]),P=s=>{t(s),m(!0)},_=()=>{t(void 0),l(!0)},z=c==="agency"?"Agências Parceiras":"Contas & Empresas",D=c==="agency"?"Base de agências de publicidade parceiras.":"Base de clientes e parceiros comerciais.";return e.jsxs("div",{className:"h-full flex flex-col bg-white",children:[e.jsxs("div",{className:"flex-shrink-0 border-b border-slate-200/80",children:[e.jsxs("div",{className:"px-8 py-5 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-slate-900 tracking-tight",children:z}),e.jsx("p",{className:"text-[13px] text-slate-400 mt-0.5",children:D})]}),e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-xs text-slate-400 font-medium",children:"Total"}),e.jsx("span",{className:"text-sm font-semibold text-slate-700 tabular-nums",children:i.total})]}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 inline-block"}),e.jsx("span",{className:"text-xs text-slate-400 font-medium",children:"Ativos"}),e.jsx("span",{className:"text-sm font-semibold text-slate-700 tabular-nums",children:i.active})]}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-500 inline-block"}),e.jsx("span",{className:"text-xs text-slate-400 font-medium",children:"Prospecção"}),e.jsx("span",{className:"text-sm font-semibold text-slate-700 tabular-nums",children:i.prospect})]})]}),e.jsx("div",{className:"h-5 w-px bg-slate-200"}),e.jsxs("button",{onClick:_,className:"px-4 py-1.5 bg-slate-900 text-white rounded-lg text-[13px] font-medium hover:bg-slate-800 transition-colors flex items-center gap-1.5",children:[e.jsx(q,{size:14})," Nova Conta"]})]})]}),e.jsxs("div",{className:"px-8 pb-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative w-80",children:[e.jsx(J,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-slate-300"}),e.jsx("input",{type:"text",placeholder:"Buscar por nome ou CNPJ...",className:"w-full pl-9 pr-3 py-1.5 bg-transparent border border-slate-200 rounded-lg text-[13px] text-slate-700 focus:outline-none focus:border-slate-400 placeholder:text-slate-300 transition-colors",value:x,onChange:s=>y(s.target.value)})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{value:o,onChange:s=>j(s.target.value),className:"appearance-none px-3 py-1.5 pr-7 bg-transparent border border-slate-200 rounded-lg text-[13px] text-slate-600 font-medium focus:outline-none focus:border-slate-400 cursor-pointer transition-colors",children:[e.jsx("option",{value:"all",children:"Todos"}),e.jsx("option",{value:"active",children:"Ativos"}),e.jsx("option",{value:"prospect",children:"Prospecção"})]}),e.jsx(G,{size:12,className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-slate-400 pointer-events-none"})]})]}),e.jsxs("span",{className:"text-[12px] text-slate-400 font-medium tabular-nums",children:[w.length," contas"]})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:N?e.jsxs("div",{className:"h-full flex flex-col items-center justify-center gap-3",children:[e.jsx(Q,{className:"w-5 h-5 text-slate-300 animate-spin"}),e.jsx("p",{className:"text-[13px] text-slate-400",children:"Carregando contas..."})]}):e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{className:"sticky top-0 z-10 bg-slate-50/80 backdrop-blur-sm",children:e.jsxs("tr",{className:"border-b border-slate-200/80",children:[e.jsx("th",{className:"px-8 py-2.5 text-[12px] font-medium text-slate-400",children:"Conta"}),e.jsx("th",{className:"px-4 py-2.5 text-[12px] font-medium text-slate-400",children:"Tipo"}),e.jsx("th",{className:"px-4 py-2.5 text-[12px] font-medium text-slate-400",children:"CNPJ"}),e.jsx("th",{className:"px-4 py-2.5 text-[12px] font-medium text-slate-400",children:"Website"}),e.jsx("th",{className:"px-4 py-2.5 text-[12px] font-medium text-slate-400 text-center",children:"Status"}),e.jsx("th",{className:"px-8 py-2.5 text-[12px] font-medium text-slate-400 text-right",children:"Ações"})]})}),e.jsx("tbody",{className:"text-[13px]",children:w.length>0?w.map(s=>e.jsxs("tr",{onClick:()=>P(s),className:"border-b border-slate-100 hover:bg-slate-50/50 transition-colors group cursor-pointer",children:[e.jsx("td",{className:"px-8 py-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-8 h-8 rounded flex-shrink-0 flex items-center justify-center border ${s.type==="agency"?"bg-purple-50 border-purple-100 text-purple-500":"bg-blue-50 border-blue-100 text-blue-500"}`,children:s.type==="agency"?e.jsx(A,{size:14}):e.jsx(S,{size:14})}),e.jsx("p",{className:"font-medium text-slate-800 truncate",children:s.name})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-[12px] text-slate-500",children:s.type==="agency"?"Agência":"Direto"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-[12px] text-slate-500 font-mono tabular-nums",children:s.document||e.jsx("span",{className:"text-slate-300",children:" -"})})}),e.jsx("td",{className:"px-4 py-3",children:s.website?e.jsxs("a",{href:s.website.startsWith("http")?s.website:`https://${s.website}`,target:"_blank",rel:"noopener noreferrer",onClick:u=>u.stopPropagation(),className:"text-[12px] text-blue-600 hover:underline flex items-center gap-1 truncate max-w-[200px]",children:[e.jsx(V,{size:11,className:"flex-shrink-0"}),s.website.replace("https://","").replace("http://","")]}):e.jsx("span",{className:"text-[12px] text-slate-300",children:" -"})}),e.jsx("td",{className:"px-4 py-3 text-center",children:e.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${s.status==="active"?"bg-emerald-500":"bg-amber-500"}`}),e.jsx("span",{className:"text-[12px] text-slate-500 font-medium",children:s.status==="active"?"Ativo":"Prospecção"})]})}),e.jsx("td",{className:"px-8 py-3 text-right",children:e.jsx("div",{className:"flex items-center justify-end gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(H,{size:14,className:"text-slate-300"})})})]},s.id)):e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-8 py-16 text-center text-[13px] text-slate-400",children:"Nenhuma conta encontrada."})})})]})}),e.jsx(B,{isOpen:p,onClose:()=>l(!1),onSave:f,account:h}),h&&e.jsx(X,{isOpen:d,onClose:()=>m(!1),account:h})]})};export{he as AdsAccounts};

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.