PageSourceSearch

https://hyscore.io/assets/admin.mail-log-TXTkXx6d.js

js hyscore.io collected 2026-10-01 11:35:28 UTC 17,431 bytes, 1 lines download raw bytes

1import{a3 as P,a4 as T,a5 as B,bI as $,b as R,a6 as G,r as n,f as K,j as e,L as A}from"./index-DfAU25pB.js";import{r as Z}from"./article-mail.functions-S5f3Qtvr.js";const J=P({method:"POST"}).middleware([T]).handler(B("c9a85849d27650c1ab9b7709c92cdaee62e0b44ab21de715692e126446c52f90")),W=P({method:"POST"}).middleware([T]).handler(B("111331e9fba81dec9cc45f23cb91aa0e6e49925feb367a777bc0d04169645c40")),H=P({method:"POST"}).middleware([T]).handler(B("3e14bf9a1427c34a59ad34072ec6f38740812403da547c12189bd4cf87a287f9"));function se(){const t=$.useSearch(),i=R(J),d=R(W),b=G(),[j,x]=n.useState(t.status??"all"),[c,z]=n.useState(t.source??"all"),[o,v]=n.useState("all"),[m,h]=n.useState(""),[p,l]=n.useState(!0),[S,w]=n.useState(null),[g,a]=n.useState(25),[M,N]=n.useState(1),r=t.articleId??null;n.useEffect(()=>{N(1)},[c,j,o,m,p,r,g]);const f=K({queryKey:["mail-log-stats",c,r,p],queryFn:()=>d({data:{source:c,articleId:r??null,includeTests:p}}),refetchInterval:2e4}),E=K({queryKey:["mail-log-rows",c,j,o,r,m,p],queryFn:()=>i({data:{source:c,status:j,kind:o==="all"?null:o,articleId:r??null,search:m||null,includeTests:p,limit:500}}),refetchInterval:2e4}),L=E.data??[],_=L.length,C=Math.max(1,Math.ceil(_/g)),q=Math.min(M,C),I=(q-1)*g,O=L.slice(I,I+g);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"E-Mail-Versandprotokoll"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Alle vom System an Kontakte versendeten E-Mails – Newsletter, Artikel-Mails, DOI-Bestätigungen und CRM-/Sequenz-Mails. Aktualisiert alle 20 s."}),r&&e.jsxs("p",{className:"mt-1 text-xs text-amber-700 dark:text-amber-300",children:["Gefiltert auf Artikel-ID ",e.jsx("span",{className:"font-mono",children:r}),"."," ",e.jsx(A,{to:"/admin/mail-log",className:"underline",children:"Filter entfernen"})]})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(A,{to:"/admin/newsletter/article-log",className:"rounded-md border border-border px-3 py-1.5 text-sm hover:bg-accent",children:"Nur Artikel-Mails"})})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-6 gap-3",children:[e.jsx(y,{label:"Gesamt",value:f.data?.total??"–"}),e.jsx(y,{label:"Queued",value:f.data?.queued??"–",tone:"warn"}),e.jsx(y,{label:"Gesendet",value:f.data?.sent??"–",tone:"ok"}),e.jsx(y,{label:"Fehler",value:f.data?.failed??"–",tone:"err"}),e.jsx(y,{label:"Bounced",value:f.data?.bounced??"–",tone:"err"}),e.jsx(y,{label:"Suppressed",value:f.data?.suppressed??"–"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:"Quelle:"}),["all","newsletter","crm"].map(s=>e.jsx("button",{onClick:()=>{z(s),v("all")},className:"px-3 py-1.5 rounded-md text-sm border transition "+(c===s?"bg-primary text-primary-foreground border-primary":"border-border hover:bg-card"),children:X(s)},s)),e.jsx("span",{className:"ml-4 text-xs uppercase tracking-wider text-muted-foreground",children:"Typ:"}),e.jsxs("select",{value:o,onChange:s=>v(s.target.value),className:"rounded-md border border-border bg-background px-2 py-1.5 text-sm",children:[e.jsx("option",{value:"all",children:"Alle Typen"}),(c==="all"||c==="newsletter")&&e.jsxs("optgroup",{label:"Newsletter",children:[e.jsx("option",{value:"newsletter",children:"Newsletter"}),e.jsx("option",{value:"article",children:"Artikel-Mail (Live)"}),e.jsx("option",{value:"article_test",children:"Artikel-Mail (Test)"}),e.jsx("option",{value:"campaign",children:"Kampagne"}),e.jsx("option",{value:"doi_confirm",children:"DOI-Bestätigung"})]}),(c==="all"||c==="crm")&&e.jsxs("optgroup",{label:"CRM",children:[e.jsx("option",{value:"crm_template",children:"Vorlage"}),e.jsx("option",{value:"crm_sequence",children:"Sequenz"}),e.jsx("option",{value:"crm_direct",children:"Direkte Mail"})]})]}),e.jsxs("label",{className:"ml-4 flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx("input",{type:"checkbox",checked:p,onChange:s=>l(s.target.checked)}),"Testversand einbeziehen"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[["all","queued","sent","failed","bounced","suppressed"].map(s=>e.jsx("button",{onClick:()=>x(s),className:"px-3 py-1.5 rounded-md text-sm border transition "+(j===s?"bg-primary text-primary-foreground border-primary":"border-border hover:bg-card"),children:Y(s)},s)),e.jsx("input",{type:"search",placeholder:"E-Mail oder Domain suchen…",value:m,onChange:s=>
1h(s.target.value),className:"ml-auto w-64 rounded-md border border-border bg-background px-3 py-1.5 text-sm"})]}),e.jsx("div",{className:"rounded-lg border border-border bg-card overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-background text-left text-xs uppercase tracking-wider text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2",children:"Status"}),e.jsx("th",{className:"px-3 py-2",children:"Quelle"}),e.jsx("th",{className:"px-3 py-2",children:"Typ"}),e.jsx("th",{className:"px-3 py-2",children:"Absender"}),e.jsx("th",{className:"px-3 py-2",children:"Empfänger"}),e.jsx("th",{className:"px-3 py-2",children:"Betreff"}),e.jsx("th",{className:"px-3 py-2",children:"Eingereiht"}),e.jsx("th",{className:"px-3 py-2",children:"Gesendet"}),e.jsx("th",{className:"px-3 py-2",children:"Fehler"})]})}),e.jsxs("tbody",{children:[E.isLoading&&e.jsx("tr",{children:e.jsx("td",{colSpan:9,className:"px-3 py-6 text-center text-muted-foreground",children:"Lade…"})}),_===0&&!E.isLoading&&e.jsx("tr",{children:e.jsx("td",{colSpan:9,className:"px-3 py-6 text-center text-muted-foreground",children:"Keine Einträge."})}),O.map(s=>e.jsxs("tr",{className:"border-t border-border align-top cursor-pointer hover:bg-accent/40",onClick:()=>w(s),children:[e.jsx("td",{className:"px-3 py-2",children:e.jsx(F,{status:s.status})}),e.jsx("td",{className:"px-3 py-2",children:e.jsx(V,{source:s.source})}),e.jsxs("td",{className:"px-3 py-2 text-muted-foreground",children:[Q(s.kind),s.is_test&&e.jsx("span",{className:"ml-1 rounded bg-amber-100 px-1 text-[10px] font-medium text-amber-800 dark:bg-amber-900/40 dark:text-amber-200",children:"Test"})]}),e.jsx("td",{className:"px-3 py-2 text-muted-foreground max-w-[220px] truncate",title:s.sender_email??"",children:s.sender_email??e.jsx("span",{className:"italic",children:"–"})}),e.jsx("td",{className:"px-3 py-2",children:s.contact_id?e.jsxs(A,{to:"/admin/crm/contacts/$id",params:{id:s.contact_id},className:"text-primary hover:underline",title:s.contact_name??s.recipient_email,onClick:D=>D.stopPropagation(),children:[s.contact_name??s.recipient_email,e.jsxs("span",{className:"text-muted-foreground",children:[" · ",s.recipient_email]})]}):s.recipient_email}),e.jsx("td",{className:"px-3 py-2 max-w-[320px] truncate text-muted-foreground",title:s.subject,children:s.subject||e.jsx("span",{className:"italic",children:"(ohne Betreff)"})}),e.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:k(s.queued_at)}),e.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:k(s.sent_at)}),e.jsx("td",{className:"px-3 py-2 text-destructive max-w-md",title:s.error??"",children:s.error?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate max-w-[320px]",children:s.error}),e.jsx("button",{type:"button",onClick:D=>{D.stopPropagation(),w(s)},className:"shrink-0 rounded border border-destructive/40 px-1.5 py-0.5 text-[10px] font-medium hover:bg-destructive/10",children:"Details"})]}):e.jsx("span",{className:"text-muted-foreground",children:"–"})})]},`${s.source}:${s.id}`))]})]})}),_>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[I+1,"–",Math.min(I+g,_)," von ",_]}),e.jsxs("label",{className:"flex items-center gap-1 text-muted-foreground",children:["Pro Seite:",e.jsxs("select",{value:g,onChange:s=>a(Number(s.target.value)),className:"rounded-md border border-border bg-background px-2 py-1",children:[e.jsx("option",{value:25,children:"25"}),e.jsx("option",{value:50,children:"50"}),e.jsx("option",{value:100,children:"100"})]})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>N(s=>Math.max(1,s-1)),disabled:q<=1,className:"rounded-md border border-border px-3 py-1 hover:bg-accent disabled:opacity-40",children:"Zurück"}),e.jsxs("span",{className:"px-2 text-muted-foreground",children:["Seite ",q," / ",C]}),e.jsx("button",{type:"button",onClick:()=>N(s=>
1Math.min(C,s+1)),disabled:q>=C,className:"rounded-md border border-border px-3 py-1 hover:bg-accent disabled:opacity-40",children:"Weiter"})]})]}),S&&e.jsx(U,{row:S,onClose:()=>w(null),onResent:async()=>{await Promise.all([b.invalidateQueries({queryKey:["mail-log-stats"]}),b.invalidateQueries({queryKey:["mail-log-rows"]})])}})]})}function U({row:t,onClose:i,onResent:d}){const b=R(Z),j=R(H),[x,c]=n.useState(!1),[z,o]=n.useState(!1),[v,m]=n.useState(null),[h,p]=n.useState(null),l=n.useRef(null);n.useEffect(()=>()=>{l.current&&clearInterval(l.current)},[]);const S=t.source==="newsletter"&&(t.kind==="article"||t.kind==="article_test")&&(t.status==="failed"||t.status==="queued")&&!!t.recipient_email;function w(a){l.current&&clearInterval(l.current);let M=0;const N=async()=>{M++;try{const r=await j({data:{source:"newsletter",sendId:a}});r&&(p({id:r.id,status:r.status,queued_at:r.queued_at,sent_at:r.sent_at,error:r.error}),(r.status==="sent"||r.status==="failed"||r.status==="bounced"||r.status==="suppressed")&&l.current&&(clearInterval(l.current),l.current=null,await d?.()))}catch{}M>=40&&l.current&&(clearInterval(l.current),l.current=null)};N(),l.current=setInterval(N,3e3)}async function g(){if(!x){c(!0),m(null);try{const a=await b({data:{sendId:t.id}});m({tone:"ok",text:`Neuer Versand erfolgreich (neue Zeile: ${a.newSendId??"?"}).`}),a.newSendId?(p({id:a.newSendId,status:"queued",queued_at:new Date().toISOString(),sent_at:null,error:null}),w(a.newSendId)):await d?.()}catch(a){m({tone:"err",text:a instanceof Error?a.message:"Neu-Versand fehlgeschlagen."})}finally{c(!1)}}}return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:i,children:[e.jsxs("div",{className:"w-full max-w-2xl rounded-lg border border-border bg-card p-6 shadow-lg",onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Versanddetails"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.source==="newsletter"?"Newsletter":"CRM"," · ID: ",t.id]})]}),e.jsx("button",{type:"button",onClick:i,className:"rounded-md border border-border px-2 py-1 text-sm hover:bg-accent",children:"Schließen"})]}),e.jsxs("dl",{className:"mt-4 grid grid-cols-3 gap-3 text-sm",children:[e.jsx(u,{label:"Status",value:e.jsx(F,{status:t.status})}),e.jsx(u,{label:"Quelle",value:e.jsx(V,{source:t.source})}),e.jsx(u,{label:"Typ",value:Q(t.kind)+(t.is_test?" (Test)":"")}),e.jsx(u,{label:"Absender",value:t.sender_email??"–",span:3}),e.jsx(u,{label:"Empfänger",value:t.recipient_email,span:2}),e.jsx(u,{label:"Kontakt",value:t.contact_name??"–"}),e.jsx(u,{label:"Betreff",value:t.subject||"(ohne)",span:3}),e.jsx(u,{label:"Eingereiht",value:k(t.queued_at)}),e.jsx(u,{label:"Gesendet",value:k(t.sent_at)}),t.article_id&&e.jsx(u,{label:"Artikel",value:e.jsx(A,{to:"/admin/news/$id",params:{id:t.article_id},className:"text-primary hover:underline",children:"Öffnen"})})]}),e.jsxs("div",{className:"mt-5",children:[e.jsx("div",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Fehlergrund"}),t.error?e.jsx("pre",{className:"mt-1 max-h-72 overflow-auto whitespace-pre-wrap rounded-md border border-destructive/40 bg-destructive/5 p-3 text-xs text-destructive",children:t.error}):e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Kein Fehler protokolliert."})]}),S&&e.jsxs("div",{className:"mt-5 flex flex-wrap items-center gap-3 rounded-md border border-border bg-background/60 p-3 text-sm",children:[e.jsxs("div",{className:"flex-1 min-w-[220px]",children:[e.jsx("div",{className:"font-medium",children:"Diesen Versand neu anstoßen"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Legt eine neue Versandzeile für"," ",e.jsx("span",{className:"font-mono",children:t.recipient_email})," an und verschickt die Artikel-Mail sofort."]}),v&&e.jsx("p",{className:"mt-2 text-xs "+(v.tone==="ok"?"text-emerald-600":"text-destructive"),children:v.text}),h&&e.jsxs("div",{className:"mt-3 rounded-md border border-border bg-card p-2 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:"Aktueller Status:"}),e.jsx(F,{status:h.status}),l.current&&e.jsx("span",{className:"text-muted-foreground",children:"aktualisiert…"})]}),e.jsxs("div",{className:"mt-1 grid grid-cols-2 gap-x-3 text-muted-foreground",children:[e.jsxs("div",{children:["Eingereiht: ",k(h.queued_at)]}),e.jsxs("div",{children:["Gesendet: ",k(h.sent_at)]})]}),h.error&&e.jsx("pre",{className:"mt-1 max-h-32 overflow-auto whitespace-pre-wrap rounded border border-destructive/40 bg-destructive/5 p-2 text-[11px] text-destructive",children:h.error})]})]}),e.jsx("button",{type:"button",onClick:()=>{m(null),o(!0)},disabled:x,className:"rounded-md border border-primary bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50",children:x?"Sende…":"Erneut senden"})]}),!S&&t.source==="crm"&&t.status!=="sent"&&e.jsx("div",{className:"mt-5 rounded-md border border-border bg-background/60 p-3 text-xs text-muted-foreground",children:"Für CRM-/Sequenz-Mails erfolgt der Neu-Versand über die zugehörige Sequenz oder das E-Mail-Compose-Fenster im Kontakt."})]}),z&&e.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/60 p-4",onClick:()=>!x&&o(!1),children:e.jsxs("div",{className:"w-full max-w-md rounded-lg border border-border bg-card p-6 shadow-xl",onClick:a=>a.stopPropagation(),children:[e.jsx("h3",{className:"text-base font-semibold",children:"Neu-Versand bestätigen"}),e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["Die Artikel-Mail wird jetzt erneut an"," ",e.jsx("span",{className:"font-mono text-foreground",children:t.recipient_email})," ","verschickt. Es entsteht eine neue Versandzeile im Protokoll."]}),e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx("button",{type:"button",disabled:x,onClick:()=>o(!1),className:"rounded-md border border-border px-3 py-1.5 text-sm hover:bg-accent disabled:opacity-50",children:"Abbrechen"}),e.jsx("button",{type:"button",disabled:x,onClick:async()=>{await g(),o(!1)},className:"rounded-md border border-primary bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50",children:x?"Sende…":"Ja, erneut senden"})]})]})})]})}function u({label:t,value:i,span:d=1}
1){const b=d===3?"col-span-3":d===2?"col-span-2":"col-span-1";return e.jsxs("div",{className:b,children:[e.jsx("dt",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:t}),e.jsx("dd",{className:"mt-0.5 break-words",children:i})]})}function X(t){switch(t){case"all":return"Alle";case"newsletter":return"Newsletter / Artikel";case"crm":return"CRM"}}function Y(t){switch(t){case"all":return"Alle";case"queued":return"Queued";case"sent":return"Gesendet";case"failed":return"Fehler";case"bounced":return"Bounced";case"suppressed":return"Suppressed"}}function Q(t){switch(t){case"newsletter":return"Newsletter";case"article":return"Artikel-Mail";case"article_test":return"Artikel-Mail (Test)";case"campaign":return"Kampagne";case"doi_confirm":return"DOI-Bestätigung";case"crm_template":return"CRM-Vorlage";case"crm_sequence":return"CRM-Sequenz";case"crm_direct":return"CRM (direkt)";default:return t}}function y({label:t,value:i,tone:d}){const b=d==="ok"?"text-emerald-600":d==="warn"?"text-amber-600":d==="err"?"text-destructive":"text-foreground";return e.jsxs("div",{className:"rounded-lg border border-border bg-card p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:t}),e.jsx("div",{className:`mt-1 text-2xl font-bold ${b}`,children:i})]})}function F({status:t}){const d={queued:"bg-amber-100 text-amber-800",sent:"bg-emerald-100 text-emerald-800",failed:"bg-red-100 text-red-800",bounced:"bg-red-100 text-red-800",suppressed:"bg-zinc-200 text-zinc-700"}[t]??"bg-zinc-200 text-zinc-700";return e.jsx("span",{className:`inline-block px-2 py-0.5 rounded text-xs font-medium ${d}`,children:t})}function V({source:t}){const i=t==="newsletter"?"bg-sky-100 text-sky-800 dark:bg-sky-900/40 dark:text-sky-200":"bg-violet-100 text-violet-800 dark:bg-violet-900/40 dark:text-violet-200";return e.jsx("span",{className:`inline-block px-2 py-0.5 rounded text-xs font-medium ${i}`,children:t==="newsletter"?"Newsletter":"CRM"})}function k(t){if(!t)return"–";try{return new Date(t).toLocaleString("de-DE")}catch{return t}}export{se as component};

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.