PageSourceSearch

https://atzuma.co.il/assets/AdminCampaigns-BaU-k-NX.js

js atzuma.co.il collected 2026-10-02 07:46:56 UTC 15,462 bytes, 16 lines download raw bytes

1import{j as e}from"./index-C_Fqshtm.js";import{u as F,r as c}from"./router-BXL9ASSk.js";import"./vendor-BNcAc9ko.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};a.SENTRY_RELEASE={id:"[email protected]"}}catch{}})();try{(function(){var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},p=new a.Error().stack;p&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[p]="382d3a2d-44ce-46ef-94ba-d149c544e7e1",a._sentryDebugIdIdentifier="sentry-dbid-382d3a2d-44ce-46ef-94ba-d149c544e7e1")})()}catch{}const f=["[email protected]","[email protected]","[email protected]"],P=()=>{const a=F(),[p,w]=c.useState([]),[v,m]=c.useState(!0),[I,S]=c.useState(null),[k,y]=c.useState(!1),[s,g]=c.useState({name:"",subject:"",sendgrid_template_id:"",target_petition_id:"",exclude_petition_id:""}),[j,_]=c.useState(null),[x,C]=c.useState(null),[r,l]=c.useState(null),[h,o]=c.useState(null),b=
1async()=>{try{m(!0);const t=localStorage.getItem("auth_token"),i=await fetch("/api/v1/admin/campaigns",{headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"}});if(!i.ok)throw new Error("Failed to fetch campaigns");const n=await i.json();w(n.campaigns||[])}catch(t){S(t instanceof Error?t.message:"Failed to load campaigns")}finally{m(!1)}};c.useEffect(()=>{window.scrollTo(0,0),b()},[]);const T=async t=>{t.preventDefault(),l("create"),o(null);try{const i=localStorage.getItem("auth_token"),n=await fetch("/api/v1/admin/campaigns",{method:"POST",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json"},body:JSON.stringify({...s,target_petition_id:s.target_petition_id?parseInt(s.target_petition_id):null,exclude_petition_id:s.exclude_petition_id?parseInt(s.exclude_petition_id):null})});if(!n.ok){const d=await n.json();throw new Error(d.message||"Failed to create campaign")}o({type:"success",text:"Campaign created successfully!"}),y(!1),g({name:"",subject:"",sendgrid_template_id:"",target_petition_id:"",exclude_petition_id:""}),b()}catch(i){o({type:"error",text:i instanceof Error?i.message:"Failed to create campaign"})}finally{l(null)}},$=async t=>{if(confirm("This will build the recipient list. Continue?")){l(`build-${t}`),o(null);try{const i=localStorage.getItem("auth_token"),n=await fetch(`/api/v1/admin/campaigns/${t}/build-recipients`,{method:"POST",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json"}});if(!n.ok){const u=await n.json();throw new Error(u.message||"Failed to build recipients")}const d=await n.json();o({type:"success",text:`Built recipient list with ${d.total_recipients} recipients`}),b()}catch(i){o({type:"error",text:i instanceof Error?i.message:"Failed to build recipients"})}finally{l(null)}}},R=async t=>{if(confirm(`Send preview to:
2${f.join(`
3`)}
4
5Continue?`)){l(`preview-${t}`),o(null);try{const i=localStorage.getItem("auth_token"),n=await fetch(`/api/v1/admin/campaigns/${t}/preview`,{method:"POST",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json"}});if(!n.ok){const d=await n.json();throw new Error(d.message||"Failed to send preview")}o({type:"success",text:`Preview sent to: ${f.join(", ")}`})}catch(i){o({type:"error",text:i instanceof Error?i.message:"Failed to send preview"})}finally{l(null)}}},z=async t=>{if(confirm("Send test email to [email protected] only?")){l(`single-${t}`),o(null);try{const i=localStorage.getItem("auth_token"),n=await fetch(`/api/v1/admin/campaigns/${t}/preview?single_test=true`,{method:"POST",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json"}});if(!n.ok){const u=await n.json();throw new Error(u.message||"Failed to send single test")}const d=await n.json();o({type:"success",text:`Single test sent to: ${d.test_emails?.join(", ")||"[email protected]"}`})}catch(i){o({type:"error",text:i instanceof Error?i.message:"Failed to send single test"})}finally{l(null)}}},B=async(t,i)=>{if(confirm(`⚠️ ATTENTION!
6
7This will send the campaign to ${i} recipients.
8
9This action cannot be undone!
10
11Are you absolutely sure?`)&&confirm(`🔴 FINAL CONFIRMATION
12
13Sending to ${i} real email addresses.
14
15Proceed?`)){l(`send-${t}`),o(null);try{const n=localStorage.getItem("auth_token"),d=await fetch(`/api/v1/admin/campaigns/${t}/send`,{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"}});if(!d.ok){const u=await d.json();throw new Error(u.message||"Failed to send campaign")}o({type:"success",text:`Campaign is being sent to ${i} recipients`}),b()}catch(n){o({type:"error",text:n instanceof Error?n.message:"Failed to send campaign"})}finally{l(null)}}},E=async t=>{_(t);try{const i=localStorage.getItem("auth_token"),n=await fetch(`/api/v1/admin/campaigns/${t.id}/stats`,{headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json"}});if(!n.ok)throw new Error("Failed to fetch stats");const d=await n.json();C(d.stats)}catch(i){console.error("Failed to fetch campaign stats:",i)}},A=t=>{const i={draft:{bg:"#f3f4f6",text:"#374151"},scheduled:{bg:"#dbeafe",text:"#1d4ed8"},sending:{bg:"#fef3c7",text:"#d97706"},sent:{bg:"#d1fae5",text:"#059669"},cancelled:{bg:"#fee2e2",text:"#dc2626"}},n=i[t]||i.draft;return e.jsx("span",{style:{padding:"4px 12px",borderRadius:"9999px",fontSize:"12px",fontWeight:600,backgroundColor:n.bg,color:n.text},children:t.toUpperCase()})};return v?e.jsxs("div",{style:{padding:"40px",textAlign:"center"}
15,children:[e.jsx("div",{style:{fontSize:"24px",marginBottom:"16px"},children:"⏳"}),e.jsx("p",{children:"Loading campaigns..."})]}):e.jsx("div",{style:{minHeight:"100vh",background:"#f9fafb",padding:"24px"},children:e.jsxs("div",{style:{maxWidth:"1200px",margin:"0 auto"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px"},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:"28px",fontWeight:"bold",color:"#111827",margin:0},children:"📧 Email Campaigns"}),e.jsx("p",{style:{color:"#6b7280",marginTop:"4px"},children:"Manage email marketing campaigns"})]}),e.jsxs("div",{style:{display:"flex",gap:"12px"},children:[e.jsx("button",{onClick:()=>a("/admin/main"),style:{padding:"10px 20px",background:"white",border:"1px solid #d1d5db",borderRadius:"8px",cursor:"pointer"},children:"← Back to Admin"}),e.jsx("button",{onClick:()=>y(!0),style:{padding:"10px 20px",background:"#059669",color:"white",border:"none",borderRadius:"8px",cursor:"pointer",fontWeight:600},children:"+ Create Campaign"})]})]}),h&&e.jsxs("div",{style:{padding:"16px",borderRadius:"8px",marginBottom:"24px",background:h.type==="success"?"#d1fae5":"#fee2e2",color:h.type==="success"?"#065f46":"#991b1b",border:`1px solid ${h.type==="success"?"#a7f3d0":"#fecaca"}`},children:[h.type==="success"?"✅":"❌"," ",h.text]}),e.jsxs("div",{style:{padding:"16px",background:"#eff6ff",borderRadius:"8px",marginBottom:"24px",border:"1px solid #bfdbfe"},children:[e.jsx("strong",{children:"📋 Preview Test Emails:"}),e.jsx("div",{style:{marginTop:"8px",color:"#1e40af"},children:f.map((t,i)=>e.jsxs("span",{children:[t,i<f.length-1?", ":""]},t))})]}),k&&e.jsxs("div",{style:{background:"white",borderRadius:"12px",padding:"24px",marginBottom:"24px",boxShadow:"0 1px 3px rgba(0,0,0,0.1)"},children:[e.jsx("h2",{style:{fontSize:"20px",fontWeight:"bold",marginBottom:"20px"},children:"Create New Campaign"}),e.jsxs("form",{onSubmit:T,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:"6px",fontWeight:500},children:"Campaign Name *"}),e.jsx("input",{type:"text",required:!0,value:s.name,onChange:t=>g({...s,name:t.target.value}),placeholder:"e.g., Bear Petition December 2024",style:{width:"100%",padding:"10px",border:"1px solid #d1d5db",borderRadius:"6px"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:"6px",fontWeight:500},children:"Email Subject *"}),e.jsx("input",{type:"text",required:!0,value:s.subject,onChange:t=>g({...s,subject:t.target.value}),placeholder:"e.g., 🐻 Help Stop Bear Slaughter",style:{width:"100%",padding:"10px",border:"1px solid #d1d5db",borderRadius:"6px"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:"6px",fontWeight:500},children:"SendGrid Template ID *"}),e.jsx("input",{type:"text",required:!0,value:s.sendgrid_template_id,onChange:t=>g({...s,sendgrid_template_id:t.target.value}),placeholder:"e.g., d-7065e47c1cc04d18a4afbc7452478830",style:{width:"100%",padding:"10px",border:"1px solid #d1d5db",borderRadius:"6px",fontFamily:"monospace"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:"6px",fontWeight:500},children:"Target Petition ID (to promote)"}),e.jsx("input",{type:"number",value:s.target_petition_id,onChange:t=>g({...s,target_petition_id:t.target.value}),placeholder:"e.g., 137",style:{width:"100%",padding:"10px",border:"1px solid #d1d5db",borderRadius:"6px"}})]}),e.jsxs("div",{style:{gridColumn:"span 2"},children:[e.jsx("label",{style:{display:"block",marginBottom:"6px",fontWeight:500},children:"Exclude Petition ID (don't send to signers of this petition)"}),e.jsx("input",{type:"number",value:s.exclude_petition_id,onChange:t=>g({...s,exclude_petition_id:t.target.value}),placeholder:"e.g., 137",style:{width:"100%",padding:"10px",border:"1px solid #d1d5db",borderRadius:"6px"}}),e.jsx("p",{style:{fontSize:"12px",color:"#6b7280",marginTop:"4px"},children:"Users who already signed this petition will NOT receive the email"})]})]}),e.jsxs("div",{style:{display:"flex",gap:"12px",marginTop:"20px"},children:[e.jsx("button",{type:"submit",disabled:r==="create",style:{padding:"10px 24px",background:"#059669",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontWeight:600,opacity:r==="create"?.7:1},children:r==="create"?"Creating...":"Create Campaign"}),e.jsx("button",{type:"button",onClick:()=>y(!1),style:{padding:"10px 24px",background:"white",border:"1px solid #d1d5db",borderRadius:"6px",cursor:"pointer"},children:"Cancel"})]})]})]}),e.jsxs("div",{style:{background:"white",borderRadius:"12px",padding:"24px",boxShadow:"0 1px 3px rgba(0,0,0,0.1)"},children:[e.jsxs("h2",{style:{fontSize:"20px",fontWeight:"bold",marginBottom:"20px"},children:["Campaigns (",p.length,")"]}),p.length===0?e.jsxs("div",{style:{textAlign:"center",padding:"40px",color:"#6b7280"}
15,children:[e.jsx("div",{style:{fontSize:"48px",marginBottom:"16px"},children:"📭"}),e.jsx("p",{children:"No campaigns yet. Create your first campaign!"})]}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:p.map(t=>e.jsxs("div",{style:{border:"1px solid #e5e7eb",borderRadius:"8px",padding:"20px",background:j?.id===t.id?"#f9fafb":"white"},children:[e.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"8px"},children:[e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,margin:0},children:t.name}),A(t.status)]}),e.jsxs("p",{style:{color:"#6b7280",margin:"4px 0"},children:["Subject: ",t.subject]}),e.jsxs("div",{style:{display:"flex",gap:"24px",marginTop:"12px",fontSize:"14px"},children:[e.jsxs("span",{children:["📊 Recipients: ",e.jsx("strong",{children:t.total_recipients})]}),e.jsxs("span",{children:["✉️ Sent: ",e.jsx("strong",{children:t.sent_count})]}),e.jsxs("span",{children:["👀 Opened: ",e.jsx("strong",{children:t.opened_count})]}),e.jsxs("span",{children:["🖱️ Clicked: ",e.jsx("strong",{children:t.clicked_count})]}),e.jsxs("span",{children:["✍️ Signed: ",e.jsx("strong",{children:t.signed_count})]}),e.jsxs("span",{children:["💰 Paid: ",e.jsx("strong",{children:t.paid_count})]})]})]})}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"16px",flexWrap:"wrap"},children:[t.status==="draft"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>$(t.id),disabled:r===`build-${t.id}`,style:{padding:"8px 16px",background:"#3b82f6",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"14px",opacity:r===`build-${t.id}`?.7:1},children:r===`build-${t.id}`?"⏳ Building...":"📋 Build Recipients"}),e.jsx("button",{onClick:()=>R(t.id),disabled:r===`preview-${t.id}`,style:{padding:"8px 16px",background:"#8b5cf6",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"14px",opacity:r===`preview-${t.id}`?.7:1},children:r===`preview-${t.id}`?"⏳ Sending...":"🧪 Send Preview"}),e.jsx("button",{onClick:()=>z(t.id),disabled:r===`single-${t.id}`,style:{padding:"8px 16px",background:"#3b82f6",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"14px",opacity:r===`single-${t.id}`?.7:1},children:r===`single-${t.id}`?"⏳ Sending...":"🔬 Single Test"}),t.total_recipients>0&&e.jsx("button",{onClick:()=>B(t.id,t.total_recipients),disabled:r===`send-${t.id}`,style:{padding:"8px 16px",background:"#dc2626",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"14px",opacity:r===`send-${t.id}`?.7:1},children:r===`send-${t.id}`?"⏳ Sending...":`🚀 Send to ${t.total_recipients}`})]}),e.jsx("button",{onClick:()=>E(t),style:{padding:"8px 16px",background:"white",border:"1px solid #d1d5db",borderRadius:"6px",cursor:"pointer",fontSize:"14px"},children:"📊 View Stats"})]}),j?.id===t.id&&x&&e.jsxs("div",{style:{marginTop:"20px",padding:"20px",background:"#f9fafb",borderRadius:"8px",border:"1px solid #e5e7eb"},children:[e.jsx("h4",{style:{margin:"0 0 16px 0",fontWeight:600},children:"Campaign Statistics"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:"16px"},children:[e.jsxs("div",{style:{background:"white",padding:"16px",borderRadius:"8px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"24px",fontWeight:"bold",color:"#3b82f6"},children:x.recipients.sent}),e.jsx("div",{style:{fontSize:"14px",color:"#6b7280"},children:"Sent"})]}),e.jsxs("div",{style:{background:"white",padding:"16px",borderRadius:"8px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"24px",fontWeight:"bold",color:"#8b5cf6"},children:x.engagement.open_rate}),e.jsx("div",{style:{fontSize:"14px",color:"#6b7280"},children:"Open Rate"})]}),e.jsxs("div",{style:{background:"white",padding:"16px",borderRadius:"8px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"24px",fontWeight:"bold",color:"#059669"},children:x.conversions.conversion_rate}),e.jsx("div",{style:{fontSize:"14px",color:"#6b7280"},children:"Conversion Rate"})]}),e.jsxs("div",{style:{background:"white",padding:"16px",borderRadius:"8px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"24px",fontWeight:"bold",color:"#dc2626"},children:x.conversions.total_revenue}),e.jsx("div",{style:{fontSize:"14px",color:"#6b7280"},children:"Revenue"})]})]}),Object.keys(x.click_sources).length>0&&e.jsxs("div",{style:{marginTop:"16px"},children:[e.jsx("h5",{style:{margin:"0 0 8px 0",fontWeight:600},children:"Click Sources"}),e.jsx("div",{style:{display:"flex",gap:"12px",flexWrap:"wrap"},children:Object.entries(x.click_sources).map(([i,n])=>e.jsxs("span",{style:{padding:"4px 12px",background:"#e0e7ff",borderRadius:"9999px",fontSize:"14px"},children:[i,": ",n]},i))})]})]})]},t.id))})]})]})})};export{P as default};
16//# sourceMappingURL=AdminCampaigns-BaU-k-NX.js.map

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.