PageSourceSearch

https://documentalize.com.br/assets/admin.quiz-leads-D_0naMS9.js

js documentalize.com.br collected 2026-09-24 14:11:47 UTC 9,057 bytes, 2 lines download raw bytes

1import{r as d,j as e}from"./vendor-react-CT5JKzvF.js";import{u as N}from"./useServerFn-kxjkcKU-.js";import{t as f}from"./index-DI3WHhBW.js";import{l as k,d as z}from"./quiz-leads.functions-e2GAnk37.js";import{D as M}from"./download-CTVB-ez5.js";import{S as E,M as R}from"./index-Cq_2mKaI.js";import{L as D}from"./loader-circle-BsPxg2oG.js";import{C as T}from"./circle-check-Bdw5sfkM.js";import{C as U}from"./circle-dashed-CCioP9Mo.js";import{T as A}from"./trash-2-Dq88e1rD.js";import"./vendor-router-DnYuAPye.js";import"./auth-middleware-CbhMS6x4.js";const b=l=>new Date(l).toLocaleString("pt-BR",{dateStyle:"short",timeStyle:"short"});function B(l){if(!l||l.includes("@"))return null;const n=l.replace(/\D/g,"");return n.length<8?null:`https://wa.me/${n.startsWith("55")?n:`55${n}`}`}const Q={alto:{bg:"var(--adm-danger-alt-2-18)",fg:"var(--adm-danger-tint-2)",label:"Alto"},medio:{bg:"var(--adm-warning-18)",fg:"var(--adm-warning-tint-2)",label:"Médio"},baixo:{bg:"var(--adm-success-alt-18)",fg:"var(--adm-success-tint-2)",label:"Baixo"}};function X(){const l=N(k),n=N(z),[g,v]=d.useState(!0),[c,j]=d.useState([]),[m,y]=d.useState(""),[x,w]=d.useState("all"),[p,S]=d.useState("all");d.useEffect(()=>{let a=!1;return v(!0),l({data:{...x!=="all"?{completo:x}:{},...p!=="all"?{nivel:p}:{},...m.trim()?{search:m.trim()}:{}}}).then(s=>{a||j(s.leads)}).catch(s=>f.error(s?.message??"Erro ao carregar")).finally(()=>!a&&v(!1)),()=>{a=!0}},[l,x,p,m]);const u=d.useMemo(()=>{const a=c.length,s=c.filter(r=>r.completo).length,o=a>0?Math.round(s/a*100):0,h=c.filter(r=>r.score!=null).reduce((r,i)=>r+(i.score??0),0)/Math.max(1,c.filter(r=>r.score!=null).length);return{total:a,completos:s,taxaConversao:o,scoreMedio:Math.round(h)}},[c]);function C(){const a=["Data","Completo","Etapa","Score","Nível","Nome","Contato","Setor","Volume","Tempo busca","Fiscalização","Perdeu doc","Conhece dec.","UTM Source","UTM Medium","UTM Campaign","Referer"],s=c.map(t=>[b(t.created_at),t.completo?"Sim":"Não",t.etapa_atual,t.score??"",t.nivel_risco??"",t.nome??"",t.contato??"",t.setor??"",t.volume??"",t.tempo_busca??"",t.fiscalizacao??"",t.perdeu_documento??"",t.conhece_decreto??"",t.utm_source??"",t.utm_medium??"",t.utm_campaign??"",t.referer??""]),o=[a,...s].map(t=>t.map(L=>`"${String(L).replace(/"/g,'""')}"`).join(",")).join(`
2`),h=new Blob([`\uFEFF${o}`],{type:"text/csv;charset=utf-8"}),r=URL.createObjectURL(h),i=document.createElement("a");i.href=r,i.download=`quiz-documental-${new Date().toISOString().slice(0,10)}.csv`,i.click(),URL.revokeObjectURL(r)}async function _(a){if(confirm("Excluir esse registro?"))try{await n({data:{id:a}}),j(s=>s.filter(o=>o.id!==a)),f.success("Removido")}catch(s){f.error(s.message)}}return e.jsxs("div",{className:"p-5 sm:p-8 max-w-[1400px]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-display font-bold text-adm-fg text-[24px] sm:text-[28px]",children:"Leads do Quiz Documental"}),e.jsxs("p",{className:"mt-1 text-adm-fg/60 text-[13px]",children:["Respostas e leads capturados em ",e.jsx("code",{className:"text-[12px] text-adm-fg/80",children:"/quiz-documental"})," (inclusive abandonos parciais)."]})]}),e.jsxs("button",{onClick:C,className:"inline-flex items-center gap-2 px-4 py-2 rounded-[10px] text-[13px] font-medium text-adm-fg",style:{background:"var(--adm-fg-08)",border:"1px solid var(--adm-fg-15)"},children:[e.jsx(M,{size:14})," Exportar CSV"]})]}),e.jsx("div",{className:"mt-6 grid grid-cols-2 sm:grid-cols-4 gap-3",children:[{label:"Total de sessões",value:u.total},{label:"Quizzes completos",value:u.completos},{label:"Taxa de conversão",value:`${u.taxaConversao}%`},{label:"Score médio",value:u.scoreMedio}].map(a=>e.jsxs("div",{className:"rounded-xl p-4",style:{background:"var(--adm-fg-04)",border:"1px solid var(--adm-fg-08)"},children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-adm-fg/70",children:a.label}),e.jsx("div",{className:"mt-1 text-[22px] font-bold text-adm-fg",children:a.value})]},a.label))}),e.jsxs("div",{className:"mt-6 flex gap-3 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(E,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-adm-fg/60",
2size:14}),e.jsx("input",{value:m,onChange:a=>y(a.target.value),placeholder:"Buscar nome, contato, setor...",className:"w-full pl-9 pr-3 py-2 rounded-[10px] text-[13px] text-adm-fg placeholder-white/40",style:{background:"var(--adm-fg-05)",border:"1px solid var(--adm-fg-10)"}})]}),e.jsxs("select",{value:x,onChange:a=>w(a.target.value),className:"px-3 py-2 rounded-[10px] text-[13px] text-adm-fg",style:{background:"var(--adm-fg-05)",border:"1px solid var(--adm-fg-10)"},children:[e.jsx("option",{value:"all",children:"Todos status"}),e.jsx("option",{value:"sim",children:"Completos"}),e.jsx("option",{value:"nao",children:"Parciais"})]}),e.jsxs("select",{value:p,onChange:a=>S(a.target.value),className:"px-3 py-2 rounded-[10px] text-[13px] text-adm-fg",style:{background:"var(--adm-fg-05)",border:"1px solid var(--adm-fg-10)"},children:[e.jsx("option",{value:"all",children:"Todos níveis"}),e.jsx("option",{value:"alto",children:"Risco Alto"}),e.jsx("option",{value:"medio",children:"Risco Médio"}),e.jsx("option",{value:"baixo",children:"Risco Baixo"})]})]}),e.jsx("div",{className:"mt-5 rounded-xl overflow-hidden",style:{background:"var(--adm-shade-25)",border:"1px solid var(--adm-fg-08)"},children:g?e.jsx("div",{className:"p-10 grid place-items-center text-adm-fg/60",children:e.jsx(D,{className:"animate-spin"})}):c.length===0?e.jsx("div",{className:"p-10 text-center text-adm-fg/70 text-[13px]",children:"Nenhum lead encontrado."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-[13px] text-adm-fg/80",children:[e.jsx("thead",{className:"text-[11px] uppercase tracking-wider text-adm-fg/70",style:{background:"var(--adm-fg-03)"},children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-4 py-3",children:"Status"}),e.jsx("th",{className:"text-left px-4 py-3",children:"Quando"}),e.jsx("th",{className:"text-left px-4 py-3",children:"Score"}),e.jsx("th",{className:"text-left px-4 py-3",children:"Lead"}),e.jsx("th",{className:"text-left px-4 py-3",children:"Setor"}),e.jsx("th",{className:"text-left px-4 py-3",children:"Volume"}),e.jsx("th",{className:"text-left px-4 py-3",children:"UTM"}),e.jsx("th",{className:"text-left px-4 py-3",children:"Etapa"}),e.jsx("th",{className:"px-4 py-3"})]})}),e.jsx("tbody",{children:c.map(a=>{const s=a.nivel_risco?Q[a.nivel_risco]:null,o=B(a.contato);return e.jsxs("tr",{className:"border-t",style:{borderColor:"var(--adm-fg-05)"},children:[e.jsx("td",{className:"px-4 py-3",children:a.completo?e.jsxs("span",{className:"inline-flex items-center gap-1 text-adm-success-tint text-[12px] font-medium",children:[e.jsx(T,{size:14})," Completo"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-adm-warning-tint text-[12px] font-medium",children:[e.jsx(U,{size:14})," Parcial"]})}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap text-adm-fg/60",children:b(a.created_at)}),e.jsx("td",{className:"px-4 py-3",children:a.score!=null?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-bold text-adm-fg",children:a.score}),s&&e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-bold uppercase",style:{background:s.bg,color:s.fg},children:s.label})]}):e.jsx("span",{className:"text-adm-fg/60",children:"—"})}),e.jsx("td",{className:"px-4 py-3",children:a.nome?e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-adm-fg",children:a.nome}),e.jsx("div",{className:"text-[11px] text-adm-fg/70",children:a.contato})]}):e.jsx("span",{className:"text-adm-fg/60",children:"— anônimo —"})}),e.jsx("td",{className:"px-4 py-3 text-adm-fg/70",children:a.setor??e.jsx("span",{className:"text-adm-fg/60",children:"—"})}),e.jsx("td",{className:"px-4 py-3 text-adm-fg/70",children:a.volume??e.jsx("span",{className:"text-adm-fg/60",children:"—"})}),e.jsx("td",{className:"px-4 py-3",children:a.utm_source||a.utm_campaign?e.jsxs("div",{className:"text-[11px] leading-tight",children:[e.jsx("div",{className:"text-adm-fg/70",children:a.utm_source??"—"}),e.jsx("div",{className:"text-adm-fg/60",children:a.utm_campaign??""})]}):e.jsx("span",{className:"text-adm-fg/60",children:"—"})}),e.jsxs("td",{className:"px-4 py-3 text-adm-fg/60",children:[a.etapa_atual,"/10"]}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[o&&e.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"p-1.5 rounded-md hover:bg-adm-fg/10 text-adm-success-tint",title:"Abrir WhatsApp",children:e.jsx(R,{size:14})}),e.jsx("button",{onClick:()=>_(a.id),className:"p-1.5 rounded-md hover:bg-adm-fg/10 text-adm-fg/70 hover:text-adm-danger-tint",title:"Excluir",children:e.jsx(A,{size:14})})]})})]},a.id)})})]})})})]})}export{X as component};

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.