PageSourceSearch

https://www.seanews.com.tr/assets/AdminMagazineNewsletter-DLTUfMfJ.js

js seanews.com.tr collected 2026-10-02 11:17:47 UTC 16,898 bytes, 90 lines download raw bytes

1import{f as q,r as c,b as W,j as e,k as b,m as N,n as w,l as T,I as n,B as p,L as C,o as S,g as Y}from"./index-DvhEnGG3.js";import{u as Q}from"./useMutation-5Qt1sQt-.js";import{L as r}from"./label-DBJRttG9.js";import{T as v}from"./textarea-BUxfkCtZ.js";import{D as F,b as D,c as M,d as I}from"./dialog-g0Sakdt5.js";import{T as J,a as Z,b as $,c as U}from"./tabs-BQ2O5CL_.js";import{A as _,I as ee}from"./AdminLayout-Zrrm2zl0.js";import{g as se,a as ie}from"./adminAuth-DLSKqndo.js";import{B as ae}from"./book-open-BX1a14hQ.js";import{F as te}from"./file-text-DsmeFF5q.js";import{L as re}from"./link-TCTvrcej.js";import{U as L}from"./upload-VphKdP6O.js";import{S as ne}from"./square-pen-BDbEuy1P.js";import{E as le}from"./eye-BKoNgi8M.js";import{S as de}from"./send-C33hwHzg.js";import"./chart-column-DZJB8hAl.js";import"./folder-open-Dfep7Pji.js";import"./message-square-Dgp5wLTg.js";import"./video-Cp2pAFso.js";import"./trending-up-CmFiU1GD.js";import"./anchor-DHgUDgz1.js";import"./calendar-days-BeDpXHdp.js";import"./building-2-DUT4rmqF.js";import"./users-BdUbaTLb.js";import"./vote-oaa0C-Bt.js";const P={issueNumber:"",magazineLink:"",coverImageUrl:"",editorMessageTR:"",editorMessageEN:"",subjectTR:"SeaNews Dergisi - Sayı {issue}",subjectEN:"SeaNews Magazine - Issue {issue}",pdfFile:null};function Ie(){const{toast:g}=q(),u=se(),j=c.useRef(null),m=c.useRef(null),[i,l]=c.useState(P),[A,y]=c.useState(!1),[B,x]=c.useState(!1),[E,k]=c.useState(!1),[t,d]=c.useState({greetingTR:"Sayın {name},",greetingEN:"Dear {name},",introTR:"Dergimizin {issue}. sayısını sizlerle buluşturmaktan onur duyuyoruz.",introEN:"We are honored to share issue {issue} of our magazine with you.",closingTR:"Keyifli okumalar dileriz.",closingEN:"We hope you enjoy reading.",ctaTextTR:"Dergiyi Görüntüle",ctaTextEN:"View Magazine"}),{data:O=[]}=W({queryKey:["/api/admin/subscribers",u],queryFn:async()=>{const s=await ie("/api/admin/subscribers");if(!s.ok)throw new Error("Failed to fetch subscribers");return s.json()},enabled:!!u}),h=O.filter(s=>s.isActive).length,f=Q({mutationFn:async()=>{const s=new FormData;s.append("issueNumber",i.issueNumber),s.append("magazineLink",i.magazineLink),s.append("coverImageUrl",i.coverImageUrl),s.append("editorMessageTR",i.editorMessageTR),s.append("editorMessageEN",i.editorMessageEN),s.append("subjectTR",i.subjectTR.replace("{issue}",i.issueNumber)),s.append("subjectEN",i.subjectEN.replace("{issue}",i.issueNumber)),s.append("greetingTR",t.greetingTR),s.append("greetingEN",t.greetingEN),s.append("introTR",t.introTR.replace("{issue}",i.issueNumber)),s.append("introEN",t.introEN.replace("{issue}",i.issueNumber)),s.append("closingTR",t.closingTR),s.append("closingEN",t.closingEN),s.append("ctaTextTR",t.ctaTextTR),s.append("ctaTextEN",t.ctaTextEN),i.pdfFile&&s.append("pdf",i.pdfFile);const a=await fetch("/api/admin/newsletter/send-magazine",{method:"POST",headers:{Authorization:`Bearer ${u}`},body:s});if(!a.ok){const o=await a.json();throw new Error(o.error||"Failed to send newsletter")}return a.json()},onSuccess:s=>{x(!1),g({title:"Gönderildi / Sent",description:`Newsletter ${s.sent} aboneye gönderildi / Newsletter sent to ${s.sent}
1 subscribers`}),l(P),j.current&&(j.current.value="")},onError:s=>{g({title:"Hata / Error",description:s.message,variant:"destructive"})}}),G=s=>{const a=s.target.files?.[0];a&&a.type==="application/pdf"?l(o=>({...o,pdfFile:a})):a&&g({title:"Hata",description:"Sadece PDF dosyası yükleyebilirsiniz",variant:"destructive"})},K=async s=>{const a=s.target.files?.[0];if(a){if(!a.type.startsWith("image/")){g({title:"Hata",description:"Sadece resim dosyası yükleyebilirsiniz",variant:"destructive"});return}k(!0);try{const o=new FormData;o.append("file",a);const z=await fetch("/api/admin/upload",{method:"POST",headers:{Authorization:`Bearer ${u}`},body:o});if(!z.ok)throw new Error("Upload failed");const X=await z.json();l(V=>({...V,coverImageUrl:X.url})),g({title:"Başarılı",description:"Kapak görseli yüklendi"})}catch{g({title:"Hata",description:"Görsel yüklenemedi",variant:"destructive"})}finally{k(!1),m.current&&(m.current.value="")}}},H=()=>{const s=t.introTR.replace("{issue}",i.issueNumber||"XX"),a=t.introEN.replace("{issue}",i.issueNumber||"XX");return`
2      <!DOCTYPE html>
3      <html>
4      <head>
5        <meta charset="utf-8">
6        <meta name="viewport" content="width=device-width, initial-scale=1.0">
7        <style>
8          body { font-family: Arial, sans-serif; margin: 0; padding: 0; background-color: #f5f5f5; }
9          .container { max-width: 600px; margin: 0 auto; padding: 20px; background-color: #ffffff; }
10          .header { text-align: center; padding: 20px 0; border-bottom: 2px solid #003366; }
11          .logo { font-size: 28px; font-weight: bold; color: #003366; }
12          .issue-badge { background-color: #003366; color: white; padding: 5px 15px; border-radius: 15px; font-size: 14px; display: inline-block; margin-top: 10px; }
13          .greeting { font-size: 18px; color: #333; margin: 25px 0 15px 0; }
14          .intro { font-size: 16px; line-height: 1.6; color: #333; margin: 15px 0; }
15          .section-divider { border-top: 1px dashed #ccc; margin: 30px 0; text-align: center; }
16          .lang-label { background: #f5f5f5; padding: 5px 15px; color: #666; font-size: 12px; text-transform: uppercase; }
17          .editor-section { background-color: #f8f9fa; padding: 20px; border-left: 4px solid #003366; margin: 25px 0; }
18          .editor-title { font-size: 16px; font-weight: bold; color: #003366; margin-bottom: 10px; }
19          .editor-message { font-size: 14px; line-height: 1.7; color: #555; white-space: pre-wrap; }
20          .closing { font-size: 16px; color: #333; margin: 25px 0; }
21          .cta-button { display: inline-block; background-color: #003366; color: white !important; padding: 14px 28px; text-decoration: none; border-radius: 4px; margin: 20px 0; font-weight: bold; }
22          .attachment-notice { background-color: #e8f4fd; padding: 15px; border-radius: 8px; margin: 20px 0; text-align: center; }
23          .attachment-icon { font-size: 24px; margin-bottom: 5px; }
24          .footer { font-size: 12px; color: #666; margin-top: 30px; padding-top: 20px; border-top: 1px solid #ddd; text-align: center; }
25        </style>
26      </head>
27      <body>
28        <div class="container">
29          <div class="header">
30            <div class="logo">SeaNews Magazine</div>
31            <div class="issue-badge">Sayı / Issue ${i.issueNumber||"XX"}</div>
32          </div>
33          
34          ${i.coverImageUrl?`
35          <div style="text-align: center; margin: 20px 0;">
36            <img src="${i.coverImageUrl}" alt="SeaNews Magazine Cover" style="max-width: 300px; width: 100%; height: auto; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15);" />
37          </div>
38          `:""}
39          
40          <!-- Turkish Section -->
41          <div class="greeting">${t.greetingTR.replace("{name}","Örnek Abone")}</div>
42          <div class="intro">${s}</div>
43          
44          ${i.editorMessageTR?`
45          <div class="editor-section">
46            <div class="editor-title">Editörden</div>
47            <div class="editor-message">${i.editorMessageTR}</div>
48          </div>
49          `:""}
50          
51          <div class="closing">${t.closingTR}</div>
52          
53          <div class="section-divider">
54            <span class="lang-label">English Version Below</span>
55          </div>
56          
57          <!-- English Section -->
58          <div class="greeting">${t.greetingEN.replace("{name}","Örnek Abone")}</div>
59          <div class="intro">${a}</div>
60          
61          ${i.editorMessageEN?`
62          <div class="editor-section">
63            <div class="editor-title">From the Editor</div>
64            <div class="editor-message">${i.editorMessageEN}</div>
65          </div>
66          `:""}
67          
68          <div class="closing">${t.closingEN}</div>
69          
70          ${i.magazineLink?`
71          <p style="text-align: center;">
72            <a href="${i.magazineLink}" class="cta-button">${t.ctaTextTR} / ${t.ctaTextEN}</a>
73          </p>
74          `:""}
75          
76          ${i.pdfFile?`
77          <div class="attachment-notice">
78            <div class="attachment-icon">📎</div>
79            <strong>PDF Eki / PDF Attachment:</strong> ${i.pdfFile.name}
80          </div>
81          `:""}
82          
83          <div class="footer">
84            SeaNews Magazine | www.seanewsmagazine.com<br/>
85            © ${new Date().getFullYear()} SeaNews. All rights reserved.
86          </div>
87        </div>
88      </body>
89      </html>
90    `},R=i.issueNumber&&i.magazineLink&&(i.editorMessageTR||i.editorMessageEN);return e.jsx(_,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(ae,{className:"h-6 w-6"}),"Dergi Dağıtımı / Magazine Distribution"]}),e.jsx("p",{className:"text-muted-foreground",children:"Aylık dergiyi abonelere gönderin / Send monthly magazine to subscribers"})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Aktif Abone / Active Subscribers"}),e.jsx("div",{className:"text-2xl font-bold text-primary",children:h})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(b,{children:[e.jsx(N,{children:e.jsxs(w,{className:"flex items-center gap-2",children:[e.jsx(te,{className:"h-5 w-5"}),"Dergi Bilgileri / Magazine Info"]})}),e.jsxs(T,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(r,{htmlFor:"issueNumber",children:"Sayı No / Issue Number *"}),e.jsx(n,{id:"issueNumber",type:"number",placeholder:"95",value:i.issueNumber,onChange:s=>l(a=>({...a,issueNumber:s.target.value})),"data-testid":"input-issue-number"})]}),e.jsxs("div",{children:[e.jsxs(r,{htmlFor:"magazineLink",children:[e.jsx(re,{className:"h-4 w-4 inline mr-1"}),"Dergi Linki / Magazine Link *"]}),e.jsx(n,{id:"magazineLink",type:"url",placeholder:"https://seanewsmagazine.com/issue-95",value:i.magazineLink,onChange:s=>l(a=>({...a,magazineLink:s.target.value})),"data-testid":"input-magazine-link"})]})]}),e.jsxs("div",{children:[e.jsxs(r,{htmlFor:"coverImageUrl",children:[e.jsx(ee,{className:"h-4 w-4 inline mr-1"}),"Kapak Görseli / Cover Image"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(n,{id:"coverImageUrl",type:"url",placeholder:"URL yapıştırın veya dosya yükleyin",value:i.coverImageUrl,onChange:s=>l(a=>({...a,coverImageUrl:s.target.value})),"data-testid":"input-cover-image-url",className:"flex-1"}),e.jsx("input",{type:"file",ref:m,accept:"image/*",onChange:K,className:"hidden"}),e.jsx(p,{type:"button",variant:"outline",onClick:()=>m.current?.click(),disabled:E,"data-testid":"button-upload-cover",children:E?e.jsx(C,{className:"h-4 w-4 animate-spin"}):e.jsx(L,{className:"h-4 w-4"})})]}),i.coverImageUrl&&e.jsx("div",{className:"mt-2 border rounded-lg overflow-hidden w-32",children:e.jsx("img",{src:i.coverImageUrl,alt:"Kapak önizleme",className:"w-full h-auto",onError:s=>{s.target.style.display="none"}})})]}),e.jsxs("div",{children:[e.jsxs(r,{htmlFor:"pdfUpload",children:[e.jsx(L,{className:"h-4 w-4 inline mr-1"}),"PDF Yükle / Upload PDF (Ek olarak gönderilecek)"]}),e.jsx(n,{id:"pdfUpload",ref:j,type:"file",accept:".pdf",onChange:G,className:"cursor-pointer","data-testid":"input-pdf-upload"}),i.pdfFile&&e.jsxs("p",{className:"text-sm text-green-600 mt-1",children:["✓ ",i.pdfFile.name," (",(i.pdfFile.size/1024/1024).toFixed(2)," MB)"]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(r,{htmlFor:"subjectTR",children:"Konu (TR) / Subject (TR)"}),e.jsx(n,{id:"subjectTR",value:i.subjectTR,onChange:s=>l(a=>({...a,subjectTR:s.target.value})),"data-testid":"input-subject-tr"})]}),e.jsxs("div",{children:[e.jsx(r,{htmlFor:"subjectEN",children:"Konu (EN) / Subject (EN)"}),e.jsx(n,{id:"subjectEN",value:i.subjectEN,onChange:s=>l(a=>({...a,subjectEN:s.target.value})),"data-testid":"input-subject-en"})]})]})]})]}),e.jsxs(b,{children:[e.jsxs(N,{children:[e.jsxs(w,{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"h-5 w-5"}),"Şablon Düzenle / Edit Template"]}),e.jsx(S,{children:"E-posta şablonundaki metinleri düzenleyebilirsiniz"})]}),e.jsxs(T,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(r,{children:"Selamlama (TR)"}),e.jsx(n,{value:t.greetingTR,onChange:s=>d(a=>({...a,greetingTR:s.target.value})),"data-testid":"input-greeting-tr"})]}),e.jsxs("div",{children:[e.jsx(r,{children:"Greeting (EN)"}),e.jsx(n,{value:t.greetingEN,onChange:s=>d(a=>({...a,greetingEN:s.target.value})),"data-testid":"input-greeting-en"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(r,{children:"Giriş (TR)"}),e.jsx(v,{value:t.introTR,onChange:s=>d(a=>({...a,introTR:s.target.value})),rows:2,"data-testid":"input-intro-tr"})]}),e.jsxs("div",{children:[e.jsx(r,{children:"Introduction (EN)"}),e.jsx(v,{value:t.introEN,onChange:s=>d(a=>({...a,introEN:s.target.value})),rows:2,"data-testid":"input-intro-en"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(r,{children:"Kapanış (TR)"}),e.jsx(n,{value:t.closingTR,onChange:s=>d(a=>({...a,closingTR:s.target.value})),"data-testid":"input-closing-tr"})]}),e.jsxs("div",{children:[e.jsx(r,{children:"Closing (EN)"}),e.jsx(n,{value:t.closingEN,onChange:s=>d(a=>({...a,closingEN:s.target.value})),"data-testid":"input-closing-en"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(r,{children:"Buton Metni (TR)"}),e.jsx(n,{value:t.ctaTextTR,onChange:s=>d(a=>({...a,ctaTextTR:s.target.value})),"data-testid":"input-cta-tr"})]}),e.jsxs("div",{children:[e.jsx(r,{children:"Button Text (EN)"}),e.jsx(n,{value:t.ctaTextEN,onChange:s=>d(a=>({...a,ctaTextEN:s.target.value})),"data-testid":"input-cta-en"})]})]})]})]})]}),e.jsxs(b,{children:[e.jsxs(N,{children:[e.jsx(w,{children:"Editör Mesajları / Editor Messages"}),e.jsx(S,{children:"Derginin 3. sayfasındaki editör mektubunu buraya yapıştırın"})]}),e.jsx(T,{children:e.jsxs(J,{defaultValue:"tr",className:"w-full",children:[e.jsxs(Z,{className:"grid w-full grid-cols-2",children:[e.jsx($,{value:"tr",children:"Türkçe"}),e.jsx($,{value:"en",children:"English"})]}),e.jsx(U,{value:"tr",children:e.jsx(v,{placeholder:"Editörden mektubu buraya yapıştırın...",value:i.editorMessageTR,onChange:s=>l(a=>({...a,editorMessageTR:s.target.value})),rows:10,className:"font-serif","data-testid":"input-editor-message-tr"})}),e.jsx(U,{value:"en",children:e.jsx(v,{placeholder:"Paste the editor's letter here...",value:i.editorMessageEN,onChange:s=>l(a=>({...a,editorMessageEN:s.target.value})),rows:10,className:"font-serif","data-testid":"input-editor-message-en"})})]})})]}),e.jsxs("div",{className:"flex gap-4 justify-end",children:[e.jsxs(p,{variant:"outline",onClick:()=>y(!0),disabled:!R,"data-testid":"button-preview",children:[e.jsx(le,{className:"h-4 w-4 mr-2"}),"Önizleme / Preview"]}),e.jsxs(p,{onClick:()=>x(!0),disabled:!R||h===0,"data-testid":"button-send",children:[e.jsx(de,{className:"h-4 w-4 mr-2"}),"Gönder / Send (",h," Abone)"]})]}),e.jsx(F,{open:A,onOpenChange:y,children:e.jsxs(D,{className:"max-w-3xl max-h-[90vh]",children:[e.jsx(M,{children:e.jsx(I,{children:"Önizleme / Preview (Bilingual / İki Dilli)"})}),e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsx("iframe",{srcDoc:H(),className:"w-full h-[600px]",title:"Newsletter Preview"})})]})}),e.jsx(F,{open:B,onOpenChange:x,children:e.jsxs(D,{children:[e.jsx(M,{children:e.jsx(I,{children:"Dergi Newsletterı Gönder"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{children:[e.jsxs("strong",{children:["SeaNews Sayı ",i.issueNumber]})," dergisini"," ",e.jsx("strong",{children:h})," aktif aboneye göndermek istediğinizden emin misiniz?"]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[e.jsxs("p",{children:["Konu (TR): ",i.subjectTR.replace("{issue}",i.issueNumber)]}),e.jsxs("p",{children:["Subject (EN): ",i.subjectEN.replace("{issue}",i.issueNumber)]}),i.pdfFile&&e.jsxs("p",{children:["PDF Eki: ",i.pdfFile.name]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(p,{variant:"outline",onClick:()=>x(!1),children:"İptal / Cancel"}),e.jsxs(p,{onClick:()=>f.mutate(),disabled:f.isPending,"data-testid":"button-confirm-send",children:[f.isPending&&e.jsx(C,{className:"h-4 w-4 mr-2 animate-spin"}),e.jsx(Y,{className:"h-4 w-4 mr-2"}),"Gönder / Send Now"]})]})]})]})})]})})}export{Ie 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.