1import{ac as d,r as u,u as x,j as e,z as p,B as h}from"./index-DN2_ah0N.js";import{u as f}from"./useMutation-KGGDJvMt.js";import{R as b}from"./ResourceHeader-tIfQOQ5q.js";import"./input-C2FaeClb.js";import{R as g}from"./ResourceTable-BIvCwR8_.js";import{C as i}from"./card-okpznGMv.js";import{C as j}from"./ConfirmDialog-8EQXhZtL.js";import"./purify.es-t2lEkcJL.js";import{D as v}from"./download-5DKW8Kap.js";import"./skeleton-CDfbHOJL.js";function T(){const l=d(),[t,a]=u.useState(null),{data:r,isLoading:c}=x({queryKey:["/api/admin/newsletter/subscribers"],queryFn:()=>fetch("/api/admin/newsletter/subscribers").then(s=>s.json())}),n=f({mutationFn:async s=>(await fetch(`/api/admin/newsletter/subscribers/${s}`,{method:"DELETE"})).json(),onSuccess:()=>{l.invalidateQueries({queryKey:["/api/admin/newsletter/subscribers"]}),a(null)}}),m=[{key:"email",header:"Email",render:s=>e.jsx("span",{className:"font-medium text-foreground",children:s.email})},{key:"source",header:"Source",render:s=>e.jsx("span",{className:"text-xs text-muted-foreground bg-muted px-2 py-0.5 rounded",children:s.source}),className:"w-32"},{key:"created_at",header:"Subscribed",render:s=>e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(s.created_at).toLocaleDateString()}),className:"w-36"}],o=(r==null?void 0:r.total)??0;return e.jsxs("div",{className:"space-y-6",children:[e.jsx(b,{title:"Newsletter Subscribers",description:"Emails collected via the newsletter signup form.",count:o,actions:e.jsxs("a",{href:"/api/admin/newsletter/export.csv",className:"inline-flex items-center gap-1.5 px-3 py-2 rounded-md border border-input text-sm font-medium text-foreground hover:bg-accent transition-colors",children:[e.jsx(v,{className:"w-4 h-4"}),"Export CSV"]})}),e.jsx(i,{className:"p-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(p,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-foreground",children:o.toLocaleString()}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"total subscribers"})]})]})}),e.jsx(i,{className:"overflow-hidden",children:e.jsx(g,{columns:m,data:(r==null?void 0:r.subscribers)||[],isLoading:c,emptyMessage:"No subscribers yet. The newsletter form on your site will add them here.",rowActions:s=>e.jsx(h,{variant:"ghost",size:"sm",onClick:()=>a(s),className:"text-xs text-destructive hover:text-destructive/80",children:"Remove"})})}),e.jsx(j,{open:!!t,title:"Remove Subscriber",message:`Remove ${t==null?void 0:t.email} from the newsletter? They will no longer receive emails.`,confirmLabel:"Remove",variant:"danger",onConfirm:()=>t&&n.mutate(t.id),onCancel:()=>a(null),isLoading:n.isPending})]})}export{T as NewsletterPage};
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.