module.exports=[88625,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)(""),[k,l]=(0,c.useState)(1),[m,n]=(0,c.useState)(!0);return(0,c.useEffect)(()=>{let a;n(!0),a=new URLSearchParams({page:String(k)}),g&&a.set("channel",g),i&&a.set("hasLead",i),fetch(`/api/admin/conversations?${a}`).then(a=>a.json()).then(a=>{d(a.conversations),f(a.total)}).catch(console.error).finally(()=>n(!1))},[k,g,i]),(0,b.jsxs)("div",{className:"space-y-6",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("h1",{className:"text-2xl font-bold",children:"All Conversations"}),(0,b.jsxs)("p",{className:"text-sm text-white/50",children:[e," total conversations"]})]}),(0,b.jsxs)("div",{className:"flex flex-wrap gap-3",children:[(0,b.jsxs)("select",{value:g,onChange:a=>{h(a.target.value),l(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 channels"}),(0,b.jsx)("option",{value:"web",children:"Web"}),(0,b.jsx)("option",{value:"whatsapp",children:"WhatsApp"})]}),(0,b.jsxs)("select",{value:i,onChange:a=>{j(a.target.value),l(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 conversations"}),(0,b.jsx)("option",{value:"true",children:"With leads only"})]})]}),m?(0,b.jsx)("div",{className:"py-12 text-center text-white/30",children:"Loading..."}):(0,b.jsxs)("div",{className:"space-y-2",children:[a.map(a=>(0,b.jsxs)("div",{className:"rounded-2xl border border-white/10 bg-white/5 p-4",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,b.jsx)("span",{className:`rounded-full px-2 py-0.5 text-xs font-semibold ${"whatsapp"===a.channel?"bg-green-500/20 text-green-400":"bg-[var(--color-bg-brand)]/20 text-[var(--color-accent-green-light)]"}`,children:a.channel}),(0,b.jsx)("span",{className:"text-sm font-medium",children:a.bot?.name||"Unknown bot"}),(0,b.jsxs)("span",{className:"text-xs text-white/30",children:[a.messageCount," msgs"]}),a.lead?.email&&(0,b.jsx)("span",{className:"rounded-full bg-yellow-500/20 px-2 py-0.5 text-xs text-yellow-400",children:a.lead.email}),(0,b.jsx)("span",{className:"ml-auto text-xs text-white/30",children:new Date(a.updatedAt).toLocaleString()})]}),(0,b.jsx)("p",{className:"mt-2 text-sm text-white/50",children:a.lastMessage||"No messages"})]},a._id)),0===a.length&&(0,b.jsx)("div",{className:"py-12 text-center text-white/30",children:"No conversations found"})]}),e>20&&(0,b.jsxs)("div",{className:"flex items-center justify-center gap-3",children:[(0,b.jsx)("button",{onClick:()=>l(a=>Math.max(1,a-1)),disabled:1===k,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 ",k]}),(0,b.jsx)("button",{onClick:()=>l(a=>a+1),disabled:k>=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_conversations_page_tsx_994c0390._.js.map