PageSourceSearch

https://www.gafferdistrict.com/assets/MerchantAdminSubscribersView-7_5sju-P.js

js gafferdistrict.com collected 2026-10-02 07:56:01 UTC 7,194 bytes, 3 lines download raw bytes

1import{r as a,j as e}from"./vendor-react-BKK2cemD.js";import{M as z,a as A}from"./MerchantContextBanner-BaSQMf0n.js";import{a as B}from"./vendor-router-MWzdZqT4.js";import"./vendor-posthog-DaPeprxb.js";const R=()=>{const d=B(),[l,m]=a.useState([]),[i,h]=a.useState(null),[u,x]=a.useState(!0),[p,g]=a.useState([]),[f,b]=a.useState(null),[y,j]=a.useState(!1),w=async()=>{try{const s=await fetch("/api/cms/session",{credentials:"include"});if(s.ok){const t=await s.json();t.authenticated?h(t.user):d("/merchant/login")}else d("/merchant/login")}catch(s){console.error("Failed to load session:",s),d("/merchant/login")}},N=async()=>{try{x(!0);const s=await fetch("/api/newsletter/subscribers",{credentials:"include"});if(s.ok){const t=await s.json();m(t.subscribers||[])}}catch(s){console.error("Failed to load subscribers:",s)}finally{x(!1)}},k=async()=>{try{const s=await fetch("/api/data/businesses.json");if(s.ok){const t=await s.json();g(t);const o=localStorage.getItem("selectedBusinessId"),r=t.find(n=>n.id===o)||t.find(n=>n.id==="100")||t[0];b(r||null)}}catch(s){console.error("Failed to load businesses:",s)}};a.useEffect(()=>{w(),N(),k()},[]);const v=s=>{try{return new Date(s).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return s}},[S,c]=a.useState(null),C=async s=>{try{(await fetch(`/api/newsletter/subscribers/${encodeURIComponent(s)}`,{method:"DELETE",credentials:"include"})).ok&&(m(l.filter(o=>o.email!==s)),c(null))}catch(t){console.error("Failed to delete subscriber:",t)}};return e.jsxs("div",{className:"flex h-screen overflow-hidden bg-background-light dark:bg-background-dark text-black dark:text-white",children:[e.jsx(z,{currentUser:i,selectedBusiness:f,businesses:p,handleBusinessSelect:s=>{b(s),localStorage.setItem("selectedBusinessId",s.id)},showBusinessSelector:y,setShowBusinessSelector:j}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(A,{business:null,isAdmin:(i==null?void 0:i.role)==="admin"||(i==null?void 0:i.businessId)===100}),e.jsx("header",{className:"sticky top-0 z-10 border-b border-gray-200 dark:border-white/10 bg-white/80 dark:bg-black/60 backdrop-blur-md shrink-0",children:e.jsxs("div",{className:"max-w-7xl mx-auto w-full px-8 py-6 flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-semibold mb-1 border-l-4 border-primary pl-4",children:"Newsletter Subscribers"}),e.jsx("p",{className:"text-sm text-[#8a7960] pl-4",children:"View and export your district's mailing list"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"bg-primary/10 px-4 py-2 rounded-none border border-primary/20",children:e.jsxs("span",{className:"text-sm font-semibold text-primary",children:[l.length," Total"]})}),e.jsxs("button",{onClick:()=>{const s=`Email,Subscribed At
2`+l.map(n=>`${n.email},${n.subscribedAt}`).join(`
3`),t=new Blob([s],{type:"text/csv"}),o=window.URL.createObjectURL(t),r=document.createElement("a");r.setAttribute("hidden",""),r.setAttribute("href",o),r.setAttribute("download",`subscribers_${new Date().toISOString().split("T")[0]}.csv`),document.body.appendChild(r),r.click(),document.body.removeChild(r)},className:"bg-white dark:bg-zinc-800 border border-gray-200 dark:border-zinc-700 px-6 py-2.5 rounded-none font-semibold flex items-center gap-2 hover:border-primary transition-all shadow-sm",children:[e.jsx("span",{className:"material-symbols-outlined",children:"download"}),"Export CSV"]})]})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx("div",{className:"max-w-7xl mx-auto px-8 py-8",children:u?e.jsxs("div",{className:"flex flex-col items-center justify-center h-64 gap-4",children:[e.jsx("div",{className:"size-12 border-4 border-primary/20 border-t-primary rounded-none animate-spin"}),e.jsx("p",{className:"text-[#8a7960] font-medium uppercase tracking-widest text-xs",children:"Loading mailing list..."})]}):l.length>0?e.jsx("div",{className:"bg-white dark:bg-black/40 rounded-none border border-gray-200 dark:border-white/10 overflow-hidden shadow-xl",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-gray-50 dark:bg-white/5 border-b border-gray-200 dark:border-white/10",children:[e.jsx("th",{className:"px-8 py-5 text-xs font-semibold uppercase tracking-wider text-[#8a7960]",children:"#"}),e.jsx("th",{className:"px-8 py-5 text-xs font-semibold uppercase tracking-wider text-[#8a7960]",children:"Email Address"}),e.jsx("th",{className:"px-8 py-5 text-xs font-semibold uppercase tracking-wider text-[#8a7960]",children:"Subscription Date"}),e.jsx("th",{className:"px-8 py-5 text-xs font-semibold uppercase tracking-wider text-[#8a7960] text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-white/5",children:l.map((s,t)=>e.jsxs("tr",{className:"hover:bg-gray-50/50 dark:hover:bg-white/5 transition-colors group",children:[e.jsx("td",{className:"px-8 py-5 text-sm font-medium text-muted font-mono",children:(t+1).toString().padStart(3,"0")}),e.jsx("td",{className:"px-8 py-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-8 rounded-none bg-gray-100 dark:bg-zinc-800 flex items-center justify-center shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-muted text-lg",children:"alternate_email"})}),e.jsx("span",{className:"text-sm font-semibold truncate group-hover:text-primary transition-colors",children:s.email})]})}),e.jsx("td",{className:"px-8 py-5 text-sm text-muted font-medium",children:v(s.subscribedAt)}),e.jsx("td",{className:"px-8 py-5 text-right font-semibold",children:S===s.email?e.jsxs("div",{className:"flex gap-2 justify-end animate-slide-left",children:[e.jsx("button",{onClick:()=>C(s.email),className:"px-3 py-1.5 bg-red-600 text-white text-[10px] uppercase rounded-none hover:bg-red-700 transition-all shadow-lg shadow-red-600/20",children:"Delete"}),e.jsx("button",{onClick:()=>c(null),className:"px-3 py-1.5 bg-gray-200 dark:bg-zinc-800 text-[10px] uppercase rounded-none hover:bg-gray-300 dark:hover:bg-zinc-700 transition-all font-semibold",children:"Cancel"})]}):e.jsx("button",{onClick:()=>c(s.email),className:"p-2 text-muted hover:text-red-500 transition-colors",title:"Remove Subscriber",children:e.jsx("span",{className:"material-symbols-outlined",children:"delete"})})})]},s.email))})]})}):e.jsxs("div",{className:"bg-white dark:bg-black/40 rounded-none border-2 border-dashed border-gray-200 dark:border-white/10 p-16 text-center space-y-4 shadow-xl",children:[e.jsx("div",{className:"size-20 bg-gray-50 dark:bg-white/5 rounded-none flex items-center justify-center mx-auto mb-6",children:e.jsx("span",{className:"material-symbols-outlined text-4xl text-gray-300 dark:text-zinc-600",children:"mail"})}),e.jsx("h3",{className:"text-xl font-semibold",children:"No subscribers yet"}),e.jsx("p",{className:"text-muted max-w-sm mx-auto font-medium",children:"Add a Newsletter Signup section to your pages to start collecting email addresses."})]})})})]})]})};export{R 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.