module.exports=[18987,a=>{"use strict";var b=a.i(87924),c=a.i(72131);function d(){let[a,d]=(0,c.useState)([]),[e,f]=(0,c.useState)(0),[g,h]=(0,c.useState)(""),[i,j]=(0,c.useState)(1),[k,l]=(0,c.useState)(!0),[m,n]=(0,c.useState)(new Set);function o(){l(!0);let a=new URLSearchParams({page:String(i)});g&&a.set("status",g),fetch(`/api/admin/leads?${a}`).then(a=>a.json()).then(a=>{d(a.leads),f(a.total),n(new Set)}).catch(console.error).finally(()=>l(!1))}async function p(a){0!==m.size&&(await fetch("/api/admin/leads",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({leadIds:Array.from(m),status:a})}),o())}return(0,c.useEffect)(()=>{o()},[i,g]),(0,b.jsxs)("div",{className:"space-y-6",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("h1",{className:"text-2xl font-bold",children:"All Leads"}),(0,b.jsxs)("p",{className:"text-sm text-white/50",children:[e," total leads"]})]}),(0,b.jsx)("button",{onClick:function(){let a=new URLSearchParams({format:"csv"});g&&a.set("status",g),window.open(`/api/admin/leads?${a}`,"_blank")},className:"rounded-xl border border-white/10 px-4 py-2 text-sm font-semibold text-white/70 transition hover:bg-white/10",children:"Export CSV"})]}),(0,b.jsxs)("div",{className:"flex flex-wrap gap-3",children:[(0,b.jsxs)("select",{value:g,onChange:a=>{h(a.target.value),j(1)},className:"rounded-xl border border-white/10 bg-white/5 px-4 py-2 text-sm text-white",children:[(0,b.jsx)("option",{value:"",children:"All statuses"}),(0,b.jsx)("option",{value:"new",children:"New"}),(0,b.jsx)("option",{value:"contacted",children:"Contacted"}),(0,b.jsx)("option",{value:"converted",children:"Converted"})]}),m.size>0&&(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsxs)("button",{onClick:()=>p("contacted"),className:"rounded-xl bg-blue-500/20 px-3 py-2 text-xs text-blue-400",children:["Mark Contacted (",m.size,")"]}),(0,b.jsxs)("button",{onClick:()=>p("converted"),className:"rounded-xl bg-green-500/20 px-3 py-2 text-xs text-green-400",children:["Mark Converted (",m.size,")"]})]})]}),k?(0,b.jsx)("div",{className:"py-12 text-center text-white/30",children:"Loading..."}):(0,b.jsx)("div",{className:"overflow-x-auto rounded-2xl border border-white/10",children:(0,b.jsxs)("table",{className:"min-w-full text-sm",children:[(0,b.jsx)("thead",{className:"border-b border-white/10 bg-white/5 text-left text-white/50",children:(0,b.jsxs)("tr",{children:[(0,b.jsx)("th",{className:"px-4 py-3 w-8",children:(0,b.jsx)("input",{type:"checkbox",onChange:b=>n(b.target.checked?new Set(a.map(a=>a._id)):new Set),className:"rounded"})}),(0,b.jsx)("th",{className:"px-4 py-3 font-semibold",children:"Name"}),(0,b.jsx)("th",{className:"px-4 py-3 font-semibold",children:"Email"}),(0,b.jsx)("th",{className:"px-4 py-3 font-semibold",children:"Phone"}),(0,b.jsx)("th",{className:"px-4 py-3 font-semibold",children:"Bot"}),(0,b.jsx)("th",{className:"px-4 py-3 font-semibold",children:"Status"}),(0,b.jsx)("th",{className:"px-4 py-3 font-semibold",children:"Date"})]})}),(0,b.jsx)("tbody",{className:"divide-y divide-white/5",children:a.map(a=>(0,b.jsxs)("tr",{className:"hover:bg-white/5",children:[(0,b.jsx)("td",{className:"px-4 py-3",children:(0,b.jsx)("input",{type:"checkbox",checked:m.has(a._id),onChange:()=>{var b;return b=a._id,void n(a=>{let c=new Set(a);return c.has(b)?c.delete(b):c.add(b),c})},className:"rounded"})}),(0,b.jsx)("td",{className:"px-4 py-3 font-medium",children:a.name||"—"}),(0,b.jsx)("td",{className:"px-4 py-3 text-[var(--color-accent-green-light)]",children:a.email||"—"}),(0,b.jsx)("td",{className:"px-4 py-3 text-white/50",children:a.phone||"—"}),(0,b.jsx)("td",{className:"px-4 py-3 text-xs text-white/40",children:a.botId?.name||"—"}),(0,b.jsx)("td",{className:"px-4 py-3",children:(0,b.jsx)("span",{className:`rounded-full px-2 py-0.5 text-xs font-semibold ${"new"===a.status?"bg-yellow-500/20 text-yellow-400":"contacted"===a.status?"bg-blue-500/20 text-blue-400":"bg-green-500/20 text-green-400"}`,children:a.status})}),(0,b.jsx)("td",{className:"px-4 py-3 text-xs text-white/40",children:new Date(a.createdAt).toLocaleDateString()})]},a._id))})]})}),e>20&&(0,b.jsxs)("div",{className:"flex items-center justify-center gap-3",children:[(0,b.jsx)("button",{onClick:()=>j(a=>Math.max(1,a-1)),disabled:1===i,className:"rounded-xl border border-white/10 px-4 py-2 text-sm disabled:opacity-30",children:"Previous"}),(0,b.jsxs)("span",{className:"text-sm text-white/50",children:["Page ",i]}),(0,b.jsx)("button",{onClick:()=>j(a=>a+1),disabled:i>=Math.ceil(e/20),className:"rounded-xl border border-white/10 px-4 py-2 text-sm disabled:opacity-30",children:"Next"})]})]})}a.s(["default",()=>d])}];

//# sourceMappingURL=src_app_%28admin%29_thisistheaeyesecretlogin_leads_page_tsx_b89320cc._.js.map