PageSourceSearch

https://ssocursos.com.br/assets/AdminNewsletter-DqfBDDBQ.js

js ssocursos.com.br collected 2026-10-07 15:28:41 UTC 5,380 bytes, 8 lines download raw bytes

1import{c as U,z,y as A,q as E,r as c,x as g,j as e,N as R,B as h,U as F,M as _,m as $,I as H,s as q,F as I}from"./index-Buo_quUu.js";import{C as b,c as v,a as M,b as P}from"./card-BSUnQWez.js";import{T as O,a as V,b as w,c as a,d as X,e as r}from"./table-BSnL6Omd.js";import{A as G}from"./arrow-left-DC8J2yZk.js";import{U as J}from"./user-check-DXgm8B4T.js";import{S as K}from"./search-C4Cu__dn.js";import{D as Q}from"./download-380PFizr.js";import{T as W}from"./trash-2-Dt07ZW84.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Y=U("UserX",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]),ce=()=>{const N=z();A();const{toast:y}=E(),[n,j]=c.useState([]),[C,S]=c.useState(!0),[i,T]=c.useState(""),[x,k]=c.useState("all");c.useEffect(()=>{L()},[]);const L=async()=>{const{data:s,error:t}=await g.from("newsletter_subscribers").select("*").order("created_at",{ascending:!1});!t&&s&&j(s),S(!1)},B=async s=>{const{error:t}=await g.from("newsletter_subscribers").delete().eq("id",s);t||(j(l=>l.filter(m=>m.id!==s)),y({title:"Assinante removido"}))},D=()=>{const t=`Nome,Email,Status,Data
7`+f().map(d=>`"${d.name}","${d.email}","${d.status}","${new Date(d.created_at).toLocaleDateString("pt-BR")}"`).join(`
8`),l=new Blob([t],{type:"text/csv"}),m=URL.createObjectURL(l),u=document.createElement("a");u.href=m,u.download="newsletter-subscribers.csv",u.click()},f=()=>n.filter(s=>{const t=!i||s.email.toLowerCase().includes(i.toLowerCase())||(s.name||"").toLowerCase().includes(i.toLowerCase()),l=x==="all"||s.status===x;return t&&l}),o={total:n.length,confirmed:n.filter(s=>s.status==="confirmed").length,pending:n.filter(s=>s.status==="pending").length,unsubscribed:n.filter(s=>s.status==="unsubscribed").length},p=f();return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(R,{}),e.jsxs("div",{className:"pt-28 pb-16 px-4 max-w-7xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-8",children:[e.jsx(h,{variant:"ghost",size:"icon",onClick:()=>N("/admin"),children:e.jsx(G,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Newsletter"}),e.jsx("p",{className:"text-muted-foreground",children:"Gerencie assinantes da newsletter"})]})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-8",children:[{label:"Total",value:o.total,icon:F,color:"text-primary"},{label:"Confirmados",value:o.confirmed,icon:J,color:"text-green-600"},{label:"Pendentes",value:o.pending,icon:_,color:"text-yellow-600"},{label:"Cancelados",value:o.unsubscribed,icon:Y,color:"text-red-600"}].map((s,t)=>e.jsx($.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:t*.1},children:e.jsx(b,{children:e.jsxs(v,{className:"p-4 flex items-center gap-3",children:[e.jsx(s.icon,{className:`w-8 h-8 ${s.color}`}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:s.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.label})]})]})})},t))}),e.jsxs(b,{children:[e.jsx(M,{children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-between",children:[e.jsx(P,{children:"Assinantes"}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs("div",{className:"relative",children:[e.jsx(K,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(H,{placeholder:"Buscar...",className:"pl-9 w-48",value:i,onChange:s=>T(s.target.value)})]}),e.jsxs("select",{className:"border rounded-md px-3 py-2 text-sm bg-background",value:x,onChange:s=>k(s.target.value),children:[e.jsx("option",{value:"all",children:"Todos"}),e.jsx("option",{value:"confirmed",children:"Confirmados"}),e.jsx("option",{value:"pending",children:"Pendentes"}),e.jsx("option",{value:"unsubscribed",children:"Cancelados"})]}),e.jsxs(h,{variant:"outline",size:"sm",onClick:D,children:[e.jsx(Q,{className:"w-4 h-4 mr-1"})," CSV"]})]})]})}),e.jsx(v,{children:C?e.jsx("p",{className:"text-center py-8 text-muted-foreground",children:"Carregando..."}):p.length===0?e.jsx("p",{className:"text-center py-8 text-muted-foreground",children:"Nenhum assinante encontrado"}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(O,{children:[e.jsx(V,{children:e.jsxs(w,{children:[e.jsx(a,{children:"Nome"}),e.jsx(a,{children:"Email"}),e.jsx(a,{children:"Status"}),e.jsx(a,{children:"Origem"}),e.jsx(a,{children:"Data"}),e.jsx(a,{})]})}),e.jsx(X,{children:p.map(s=>e.jsxs(w,{children:[e.jsx(r,{children:s.name||"—"}),e.jsx(r,{className:"font-mono text-sm",children:s.email}),e.jsx(r,{children:e.jsx(q,{variant:s.status==="confirmed"?"default":s.status==="pending"?"secondary":"destructive",children:s.status==="confirmed"?"Confirmado":s.status==="pending"?"Pendente":"Cancelado"})}),e.jsx(r,{className:"text-sm",children:s.source||"website"}),e.jsx(r,{className:"text-sm",children:new Date(s.created_at).toLocaleDateString("pt-BR")}),e.jsx(r,{children:e.jsx(h,{variant:"ghost",size:"icon",onClick:()=>B(s.id),children:e.jsx(W,{className:"w-4 h-4 text-destructive"})})})]},s.id))})]})})})]})]}),e.jsx(I,{})]})};export{ce 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.