PageSourceSearch

https://eventosfidelidade.lovable.app/assets/Emails-D9thSS-O.js

js eventosfidelidade.lovable.app collected 2026-10-03 03:31:05 UTC 7,249 bytes, 1 lines download raw bytes

1import{r as t,j as e,B as F,S as I,s as M,h as R}from"./index-D9XUPvtJ.js";import{I as C}from"./input-CFb8yAF4.js";import{L as n}from"./label-CsUbTWU_.js";import{B as V}from"./badge-RlcGX9Kx.js";import{S as f,a as j,b as v,c as g,d as a}from"./select-SojJpR6R.js";import{M as q}from"./mail-CQP-6I6R.js";import{C as z}from"./circle-alert-Df7XQxPN.js";import"./index-B7rhJ4gA.js";import"./index-OTDcGV2Z.js";import"./index-Czw-X86Z.js";import"./check-BPC2F_P1.js";const A={lead_cadastro:"Cadastro newsletter",inscricao_confirmada:"Inscrição confirmada",compra_confirmada:"Pagamento confirmado",pagamento_pendente:"Pagamento pendente",aviso_admin_nova_inscricao:"Aviso ao admin","welcome-registration":"Confirmação de inscrição","registration-free-confirmed":"Inscrição gratuita","registration-payment-pending":"Pagamento pendente","registration-payment-confirmed":"Pagamento confirmado"},H={sent:{label:"Enviado",className:"bg-primary/10 text-primary border-primary/20"},failed:{label:"Falhou",className:"bg-destructive/10 text-destructive border-destructive/20"},dlq:{label:"Falhou",className:"bg-destructive/10 text-destructive border-destructive/20"},pending:{label:"Pendente",className:"bg-accent/10 text-accent-foreground border-accent/20"},suppressed:{label:"Suprimido",className:"bg-muted text-muted-foreground border-border"},bounced:{label:"Rejeitado",className:"bg-destructive/10 text-destructive border-destructive/20"},complained:{label:"Reclamação",className:"bg-destructive/10 text-destructive border-destructive/20"}};function ee(){const[l,u]=t.useState([]),[h,D]=t.useState([]),[L,N]=t.useState(!0),[d,y]=t.useState("all"),[c,S]=t.useState("all"),[o,w]=t.useState("all"),[m,_]=t.useState(""),[x,E]=t.useState(""),T=async()=>{N(!0);try{const{data:s,error:r}=await M.functions.invoke("admin-email-logs",{body:{}});if(r)throw r;u((s==null?void 0:s.logs)||[]),D((s==null?void 0:s.events)||[])}catch(s){console.error("Erro ao carregar e-mails:",s),R.error((s==null?void 0:s.message)||"Erro ao carregar e-mails enviados")}finally{N(!1)}};t.useEffect(()=>{T()},[]);const i=t.useMemo(()=>l.filter(s=>!(d!=="all"&&(s.related_event_id??null)!==d||c!=="all"&&s.type!==c||o!=="all"&&s.status!==o||m&&new Date(s.created_at)<new Date(m+"T00:00:00")||x&&new Date(s.created_at)>new Date(x+"T23:59:59"))),[l,d,c,o,m,x]),p=t.useMemo(()=>({total:i.length,sent:i.filter(s=>s.status==="sent").length,failed:i.filter(s=>["failed","dlq","bounced","complained"].includes(s.status)).length}),[i]),B=t.useMemo(()=>Array.from(new Set(l.map(s=>s.type))).filter(Boolean).sort(),[l]),P=s=>new Date(s).toLocaleString("pt-BR",{dateStyle:"short",timeStyle:"short"}),k=()=>{y("all"),S("all"),w("all"),_(""),E("")};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"font-serif text-3xl flex items-center gap-2",children:[e.jsx(q,{className:"h-7 w-7 text-primary"})," E-mails enviados"]}),e.jsx("p",{className:"text-muted-foreground",children:"Histórico de mensagens disparadas pelo sistema"})]}),e.jsx(F,{variant:"outline",onClick:T,children:"Atualizar"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsx(b,{label:"Total",value:p.total}),e.jsx(b,{label:"Enviados",value:p.sent,accent:"text-primary"}),e.jsx(b,{label:"Falharam",value:p.failed,accent:"text-destructive"})]}),e.jsxs("div",{className:"rounded-2xl bg-card border border-border/50 p-5 shadow-soft space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-3",children:[e.jsxs("div",{children:[e.jsx(n,{className:"text-xs",children:"Evento"}),e.jsxs(f,{value:d,onValueChange:y,children:[e.jsx(j,{children:e.jsx(v,{})}),e.jsxs(g,{children:[e.jsx(a,{value:"all",children:"Todos"}),h.map(s=>e.jsx(a,{value:s.id,children:s.title},s.id))]})]})]}),e.jsxs("div",{children:[e.jsx(n,{className:"text-xs",children:"Tipo"}),e.jsxs(f,{value:c,onValueChange:S,children:[e.jsx(j,{children:e.jsx(v,{})}),e.jsxs(g,{children:[e.jsx(a,{value:"all",children:"Todos"}),B.map(s=>e.jsx(a,{value:s,children:A[s]??s},s))]})]})]}),e.jsxs("div",{children:[e.jsx(n,{className:"text-xs",children:"Status"}),e.jsxs(f,{value:o,onValueChange:w,children:[e.jsx(j,{children:e.jsx(v,{})}),e.jsxs(g,{children:[e.jsx(a,{value:"all",children:"Todos"}),e.jsx(a,{value:"sent",children:"Enviado"}),e.jsx(a,{value:"failed",children:"Falhou"}),e.jsx(a,{value:"dlq",children:"Falhou após tentativas"}),e.jsx(a,{value:"pending",children:"Pendente"}),e.jsx(a,{value:"suppressed",children:"Suprimido"})]})]})]}),e.jsxs("div",{children:[e.jsx(n,{className:"text-xs",children:"De"}),e.jsx(C,{type:"date",value:m,onChange:s=>_(s.target.value)})]}),e.jsxs("div",{children:[e.jsx(n,{className:"text-xs",children:"Até"}),e.jsx(C,{type:"date",value:x,onChange:s=>E(s.target.value)})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(F,{variant:"ghost",size:"sm",onClick:k,children:"Limpar filtros"})})]}),e.jsx("div",{className:"rounded-2xl bg-card border border-border/50 shadow-soft overflow-hidden",children:L?e.jsx("div",{className:"p-5 space-y-2",children:Array.from({length:5}).map((s,r)=>e.jsx(I,{className:"h-10 w-full"},r))}):i.length===0?e.jsx("div",{className:"p-10 text-center text-muted-foreground",children:"Nenhum e-mail encontrado com os filtros atuais."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-secondary/40 text-xs uppercase tracking-wider text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left p-3",children:"Destinatário"}),e.jsx("th",{className:"text-left p-3",children:"E-mail"}),e.jsx("th",{className:"text-left p-3",children:"Tipo"}),e.jsx("th",{className:"text-left p-3",children:"Evento"}),e.jsx("th",{className:"text-left p-3",children:"Status"}),e.jsx("th",{className:"text-left p-3",children:"Data"}),e.jsx("th",{className:"text-left p-3",children:"Erro"})]})}),e.jsx("tbody",{children:i.map(s=>{const r=H[s.status]??{label:s.status,className:"bg-muted text-foreground"};return e.jsxs("tr",{className:"border-t border-border/40 hover:bg-secondary/20",children:[e.jsx("td",{className:"p-3",children:s.recipient_name||"—"}),e.jsx("td",{className:"p-3 font-mono text-xs",children:s.recipient_email}),e.jsx("td",{className:"p-3",children:A[s.type]??s.type}),e.jsx("td",{className:"p-3",children:s.event_title??"—"}),e.jsx("td",{className:"p-3",children:e.jsx(V,{variant:"outline",className:r.className,children:r.label})}),e.jsx("td",{className:"p-3 whitespace-nowrap",children:P(s.created_at)}),e.jsx("td",{className:"p-3 max-w-[240px]",children:s.error_message?e.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive text-xs",children:[e.jsx(z,{className:"h-3 w-3"})," ",s.error_message]}):"—"})]},s.id)})})]})})})]})}function b({label:l,value:u,accent:h}){return e.jsxs("div",{className:"rounded-2xl bg-card border border-border/50 shadow-soft p-5",children:[e.jsx("div",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:l}),e.jsx("div",{className:`font-serif text-3xl mt-2 ${h??""}`,children:u})]})}
1export{ee 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.