1import{r as d,j as e}from"./react-vendor-BzdE_8IM.js";import{H as T,r as C}from"./app-DP4FQjf0.js";import{B as u}from"./badge-mWqGc5Tn.js";import{C as _,c as A}from"./card-DRaKzo6z.js";import{D}from"./date-range-picker-BRYxOHdi.js";import{I}from"./input-BZz0wnzE.js";import{S as L,a as P,b as B,c as E,d as o}from"./select-DJUrrphy.js";import{T as R,a as U,b as x,c as H}from"./tabs-CgzkoGE4.js";import{A as M}from"./app-layout-DLK_Th9G.js";import{S as k}from"./search-CrmZ_---.js";/* empty css */import"./ui-vendor-DxgDxQ1H.js";import"./index-CdJFUDDL.js";import"./utils-CBfrqCZ4.js";import"./button-D5IaR8Ma.js";import"./dialog-3PJxhwxc.js";import"./x-LqwSSToJ.js";import"./createLucideIcon-EVqK5FMf.js";import"./addDays-Dt8rbkuf.js";import"./format-BbT4DHjD.js";import"./calendar-DQVq1XQF.js";import"./chevron-down-VCER46nT.js";import"./check-De7Nm9hS.js";import"./tooltip-D1sUMSP8.js";import"./create-hugeicon-component-CTzdnSI-.js";import"./label-LcSwMu-C.js";import"./switch-BVb3pjwG.js";import"./avatar-DZFw-9a_.js";import"./use-initials-mHPNUr_c.js";import"./loader-circle-C2gynC-8.js";const O=[{title:"Admin",href:"/admin/dashboard"},{title:"Newsletter Subscriptions",href:"/admin/subscribers"}];function Ne({subscribers:r,statuses:V,filters:n={}}){const[m,g]=d.useState(n?.search||""),j=n?.status==="subscribed"?"subscribed":n?.status==="unsubscribed"?"unsubscribed":"all",[i,c]=d.useState(j),[p,f]=d.useState(String(n?.per_page||"10")),[N,v]=d.useState({}),a=(t={})=>{const s={search:m||void 0,status:i==="all"?void 0:i,per_page:p,...t};Object.keys(s).forEach(l=>(s[l]===void 0||s[l]===null)&&delete s[l]),C.get(route("admin.subscribers.index"),s,{preserveState:!0,replace:!0,preserveScroll:!0})},S=()=>{a({search:m,page:1})},y=t=>{switch(t){case"subscribed":return e.jsx(u,{className:"bg-green-100 text-green-800 hover:bg-green-100",children:"Subscribed"});case"unsubscribed":return e.jsx(u,{className:"bg-red-100 text-red-800 hover:bg-red-100",children:"Unsubscribed"});default:return e.jsx(u,{children:t})}},h=t=>t?new Date(t).toLocaleDateString("en-US",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):"-",b=(t=>i==="all"?t:t.filter(s=>s.status===i))(r?.data||[]);return e.jsxs(M,{breadcrumbs:O,children:[e.jsx(T,{title:"Newsletter Subscriptions Management"}),e.jsxs("div",{className:"container mx-auto space-y-6 p-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Newsletter Subscriptions"})}),e.jsx(_,{children:e.jsxs(A,{className:"p-6",children:[e.jsxs(R,{value:i,onValueChange:c,className:"w-full",children:[e.jsxs("div",{className:"mb-6 flex flex-col gap-4 md:flex-row md:items-center md:justify-between",children:[e.jsxs(U,{children:[e.jsx(x,{value:"all",onClick:()=>{c("all"),a({status:void 0})},children:"All"}),e.jsx(x,{value:"subscribed",onClick:()=>{c("subscribed"),a({status:"subscribed"})},children:"Subscribed"}),e.jsx(x,{value:"unsubscribed",onClick:()=>{c("unsubscribed"),a({status:"unsubscribed"})},children:"Unsubscribed"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(k,{className:"absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(I,{placeholder:"Search email or source...",value:m,onChange:t=>g(t.target.value),onKeyDown:t=>t.key==="Enter"&&S(),className:"w-full pl-9 md:w-64"})]}),e.jsx(D,{value:N,onChange:t=>{v(t);const s=t?.from?t.from.toISOString().slice(0,10):void 0,l=t?.to?t.to.toISOString().slice(0,10):void 0;a({from:s,to:l})},className:"min-w-[230px]"})]})]}),e.jsx(H,{value:i,className:"mt-0",children:e.jsx("div",{className:"overflow-x-auto rounded-lg border",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"border-b bg-muted",children:e.jsxs("tr",{className:"text-left",children:[e.jsx("th",{className:"p-3 font-medium text-muted-foreground",children:"Email"}),e.jsx("th",{className:"p-3 font-medium text-muted-foreground",children:"Source"}),e.jsx("th",{className:"p-3 font-medium text-muted-foreground",children:"Subscribed At"}),e.jsx("th",{className:"p-3 font-medium text-muted-foreground",children:"Unsubscribed At"}),e.jsx("th",{className:"p-3 font-medium text-muted-foreground",children:"Status"})]})}),e.jsx("tbody",{children:b.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"p-8 text-center text-muted-foreground",children:"No subscribers found"})}):b.map(t=>e.jsxs("tr",{className:"border-b hover:bg-muted/50",children:[e.jsx("td",{className:"p-3",children:e.jsx("div",{className:"font-medium",children:t.email})}),e.jsx("td",{className:"p-3",children:t.source||"-"}),e.jsx("td",{className:"p-3",children:h(t.subscribed_at)}),e.jsx("td",{className:"p-3",children:h(t.unsubscribed_at)}),e.jsx("td",{className:"p-3",children:y(t.status)})]},t.id))})]})})})]}),e.jsxs("div",{className:"flex items-center justify-between border-t border-gray-200 px-4 py-3",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Showing ",(r.current_page-1)*r.per_page+1," to"," ",Math.min(r.current_page*r.per_page,r.total)," of"," ",r.total," results"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex gap-1",children:Array.isArray(r?.links)&&r.links.map((t,s)=>e.jsx("div",{children:t.url?e.jsx("a",{href:t.url,className:`rounded-md px-3 py-2 text-sm transition-colors ${t.active?"bg-blue-500 text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200"}`,onClick:l=>{l.preventDefault();const w=new URL(t.url).searchParams.get("page")||"1";a({page:w})},dangerouslySetInnerHTML:{__html:t.label}}):e.jsx("span",{className:"cursor-not-allowed px-3 py-2 text-sm text-gray-400",dangerouslySetInnerHTML:{__html:t.label}})}
1,s))}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Show"}),e.jsxs(L,{value:p,onValueChange:t=>{f(t),a({per_page:t,page:1})},children:[e.jsx(P,{className:"w-[80px]",children:e.jsx(B,{})}),e.jsxs(E,{children:[e.jsx(o,{value:"10",children:"10"}),e.jsx(o,{value:"25",children:"25"}),e.jsx(o,{value:"50",children:"50"}),e.jsx(o,{value:"100",children:"100"})]})]})]})]})]})]})})]})]})}export{Ne 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.