PageSourceSearch

https://bhumientech.com/assets/AdminEmails-Bh7yrfdL.js

js bhumientech.com collected 2026-10-08 10:17:37 UTC 4,384 bytes, 1 lines download raw bytes

1import{r as t,j as e,s as D}from"./index-ZDIIxqz8.js";import{A as M}from"./AdminLayout-B3SVHOuu.js";import{C as T,c as C}from"./card-Df7AVyD-.js";import{B as R}from"./badge-BV7tAcfw.js";import{B as V}from"./button-CtscVDTa.js";import{S as b,a as N,b as _,c as w,d as n}from"./select-B3S41XCW.js";import{T as q,a as H,b as h,c as d,d as k,e as r}from"./table-B2ww8Kdm.js";import"./Seo-DFxv9WpT.js";import"./search-DXDANgUB.js";import"./mail-CGE7SHjU.js";import"./file-text-CXAcKtfl.js";import"./boxes-DtxSfIh3.js";import"./index-3VIYs9dO.js";import"./index-BKjHuvaR.js";import"./chevron-down-DS01F0OB.js";const F=[{label:"24h",hours:24},{label:"7d",hours:24*7},{label:"30d",hours:24*30}];function I(l){return l==="sent"?"default":l==="pending"?"secondary":["dlq","failed","bounced","complained"].includes(l)?"destructive":"outline"}function te(){const[l,j]=t.useState([]),[c,S]=t.useState(!0),[f,y]=t.useState(24*7),[o,A]=t.useState("all"),[u,L]=t.useState("all"),B=async()=>{S(!0);const s=new Date(Date.now()-f*60*60*1e3).toISOString(),{data:x}=await D.from("email_send_log").select("id, message_id, template_name, recipient_email, status, error_message, created_at").gte("created_at",s).order("created_at",{ascending:!1}).limit(1e3);j(x??[]),S(!1)};t.useEffect(()=>{B()},[f]);const a=t.useMemo(()=>{const s=new Set,x=[];for(const g of l){const v=g.message_id??g.id;s.has(v)||(s.add(v),x.push(g))}return x},[l]),E=t.useMemo(()=>Array.from(new Set(a.map(s=>s.template_name))).sort(),[a]),m=t.useMemo(()=>a.filter(s=>(o==="all"||s.template_name===o)&&(u==="all"||s.status===u)),[a,o,u]),i=t.useMemo(()=>({total:a.length,sent:a.filter(s=>s.status==="sent").length,failed:a.filter(s=>["dlq","failed","bounced"].includes(s.status)).length,pending:a.filter(s=>s.status==="pending").length}),[a]);return e.jsxs(M,{title:"Email Log",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[F.map(s=>e.jsxs(V,{size:"sm",variant:f===s.hours?"default":"outline",onClick:()=>y(s.hours),children:["Last ",s.label]},s.label)),e.jsx("div",{className:"flex-1"}),e.jsxs(b,{value:o,onValueChange:A,children:[e.jsx(N,{className:"w-[180px]",children:e.jsx(_,{placeholder:"All templates"})}),e.jsxs(w,{children:[e.jsx(n,{value:"all",children:"All templates"}),E.map(s=>e.jsx(n,{value:s,children:s},s))]})]}),e.jsxs(b,{value:u,onValueChange:L,children:[e.jsx(N,{className:"w-[140px]",children:e.jsx(_,{placeholder:"All statuses"})}),e.jsxs(w,{children:[e.jsx(n,{value:"all",children:"All statuses"}),e.jsx(n,{value:"sent",children:"Sent"}),e.jsx(n,{value:"pending",children:"Pending"}),e.jsx(n,{value:"dlq",children:"Failed (DLQ)"}),e.jsx(n,{value:"bounced",children:"Bounced"}),e.jsx(n,{value:"suppressed",children:"Suppressed"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsx(p,{label:"Total emails",value:i.total}),e.jsx(p,{label:"Sent",value:i.sent}),e.jsx(p,{label:"Failed",value:i.failed,bad:i.failed>0}),e.jsx(p,{label:"Pending",value:i.pending})]}),e.jsx(T,{children:e.jsx(C,{className:"p-0",children:e.jsxs(q,{children:[e.jsx(H,{children:e.jsxs(h,{children:[e.jsx(d,{children:"Template"}),e.jsx(d,{children:"Recipient"}),e.jsx(d,{children:"Status"}),e.jsx(d,{children:"When"}),e.jsx(d,{children:"Error"})]})}),e.jsxs(k,{children:[m.slice(0,200).map(s=>e.jsxs(h,{children:[e.jsx(r,{className:"font-mono text-xs",children:s.template_name}),e.jsx(r,{children:s.recipient_email}),e.jsx(r,{children:e.jsx(R,{variant:I(s.status),children:s.status})}),e.jsx(r,{className:"text-sm text-muted-foreground",children:new Date(s.created_at).toLocaleString()}),e.jsx(r,{className:"text-xs text-destructive max-w-xs truncate",children:s.error_message??""})]},s.id)),!c&&m.length===0&&e.jsx(h,{children:e.jsx(r,{colSpan:5,className:"text-center text-muted-foreground py-8",children:"No emails for this filter."})}),c&&e.jsx(h,{children:e.jsx(r,{colSpan:5,className:"text-center text-muted-foreground py-8",children:"Loading…"})})]})]})})}),m.length>200&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Showing first 200 of ",m.length," entries."]})]})}function p({label:l,value:j,bad:c}){return e.jsx(T,{children:e.jsxs(C,{className:"p-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:l}),e.jsx("div",{className:`text-2xl font-bold ${c?"text-destructive":""}`,children:j})]})})}export{te 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.