1import{r as U,af as q,j as e,B as g,U as O,m as w,v as W,n as u,b as x,s as b}from"./index-B6Gxx4GM.js";import{u as A}from"./useQuery-C3bj8Vn9.js";import{u as P}from"./useMutation-r1Y5CKuG.js";import{T as H,a as Q,b as N,c as n,d as V,e as i}from"./table-Dc0U_w2w.js";import{C as o,a as c,b as d,d as l,c as F}from"./card-DarvT0nx.js";import{S as K}from"./switch-DbzZusa5.js";import{C as $}from"./check-rlthyrJ0.js";import{C as Y}from"./copy-oA-lyogg.js";import{D as z}from"./download-CgwcAI_J.js";import{T as G}from"./trending-up-C04KynPD.js";import{M as I}from"./mail-B7eLQSox.js";import"./index-CThjfcc1.js";function de(){const[y,j]=U.useState(!1),v=q(),{data:t,isLoading:C}=A({queryKey:["seo-leads"],queryFn:async()=>{const{data:s,error:a}=await b.from("seo_leads").select("*").order("created_at",{ascending:!1});if(a)throw a;return s}}),_=P({mutationFn:async({id:s,value:a})=>{const{error:m}=await b.from("seo_leads").update({registered_for_webinar:a}).eq("id",s);if(m)throw m},onSuccess:()=>{v.invalidateQueries({queryKey:["seo-leads"]}),x.success("Lead updated")},onError:s=>x.error(s.message)}),T=()=>{t!=null&&t.length&&(navigator.clipboard.writeText(t.map(s=>s.email).join(", ")),j(!0),x.success("Emails copied"),setTimeout(()=>j(!1),2e3))},S=()=>{if(!(t!=null&&t.length))return;const s=["Name","Email","Business","City","Source","Registered for Webinar","Created At"],a=t.map(r=>[r.name||"",r.email,r.business_name||"",r.city||"",r.source||"",r.registered_for_webinar?"yes":"no",u(new Date(r.created_at),"PPpp")]),m=[s,...a].map(r=>r.map(M=>`"${String(M).replace(/"/g,'""')}"`).join(",")).join(` 2`),B=new Blob([m],{type:"text/csv"}),p=URL.createObjectURL(B),h=document.createElement("a");h.href=p,h.download=`seo-leads-${u(new Date,"yyyy-MM-dd")}.csv`,h.click(),URL.revokeObjectURL(p),x.success("CSV exported")},f=(t==null?void 0:t.length)||0,E=Date.now()-7*864e5,L=Date.now()-30*864e5,D=(t==null?void 0:t.filter(s=>new Date(s.created_at).getTime()>E).length)||0,k=(t==null?void 0:t.filter(s=>new Date(s.created_at).getTime()>L).length)||0,R=(t==null?void 0:t.filter(s=>s.registered_for_webinar).length)||0;return C?e.jsx("div",{className:"p-8",children:e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-1/4"}),e.jsx("div",{className:"h-64 bg-muted rounded"})]})}):e.jsxs("div",{className:"p-8 space-y-6",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"SEO Leads"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Downloads of the Local SEO guide from /seo. Toggle the webinar flag to stop follow-ups."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(g,{onClick:T,variant:"outline",children:[y?e.jsx($,{className:"mr-2 h-4 w-4"}):e.jsx(Y,{className:"mr-2 h-4 w-4"}),"Copy Emails"]}
2),e.jsxs(g,{onClick:S,children:[e.jsx(z,{className:"mr-2 h-4 w-4"}),"Export CSV"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs(o,{children:[e.jsxs(c,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(d,{className:"text-sm font-medium",children:"Total Leads"}),e.jsx(O,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(l,{children:[e.jsx("div",{className:"text-2xl font-bold",children:f}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"All time"})]})]}),e.jsxs(o,{children:[e.jsxs(c,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(d,{className:"text-sm font-medium",children:"This Week"}),e.jsx(G,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(l,{children:[e.jsx("div",{className:"text-2xl font-bold",children:D}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 7 days"})]})]}),e.jsxs(o,{children:[e.jsxs(c,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(d,{className:"text-sm font-medium",children:"This Month"}),e.jsx(I,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(l,{children:[e.jsx("div",{className:"text-2xl font-bold",children:k}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 30 days"})]})]}),e.jsxs(o,{children:[e.jsxs(c,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(d,{className:"text-sm font-medium",children:"Registered"}),e.jsx(w,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(l,{children:[e.jsx("div",{className:"text-2xl font-bold",children:R}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Webinar signups"})]})]})]}),e.jsxs(o,{children:[e.jsxs(c,{children:[e.jsxs(d,{children:["All SEO Leads (",f,")"]}),e.jsx(F,{children:'Toggle "Webinar" to remove a lead from the nurture sequence.'})]}),e.jsx(l,{children:t!=null&&t.length?e.jsx("div",{className:"rounded-md border overflow-x-auto",children:e.jsxs(H,{children:[e.jsx(Q,{children:e.jsxs(N,{children:[e.jsx(n,{children:"Name"}),e.jsx(n,{children:"Email"}),e.jsx(n,{children:"Business"}),e.jsx(n,{children:"City"}),e.jsx(n,{children:"Source"}),e.jsx(n,{children:"Downloaded"}),e.jsx(n,{children:"Webinar"})]})}),e.jsx(V,{children:t.map(s=>e.jsxs(N,{children:[e.jsx(i,{className:"font-medium",children:s.name||"â"}),e.jsx(i,{children:s.email}),e.jsx(i,{children:s.business_name||"â"}),e.jsx(i,{children:s.city||"â"}),e.jsx(i,{children:e.jsx(W,{variant:"secondary",children:s.source||"seo_page_guide"})}),e.jsx(i,{children:u(new Date(s.created_at),"PPp")}),e.jsx(i,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{checked:!!s.registered_for_webinar,onCheckedChange:a=>_.mutate({id:s.id,value:a})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:s.registered_for_webinar?"Yes":"No"})]})})]},s.id))})]})}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(w,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No leads yet. Share /seo to start collecting downloads."})]})})]})]})}export{de 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.