PageSourceSearch

https://atzuma.co.il/assets/AdminPetitionUpdates-DB9qioQf.js

js atzuma.co.il collected 2026-09-24 21:10:56 UTC 13,095 bytes, 2 lines download raw bytes

1import{j as t}from"./index-BtgGoHYl.js";import{r as i}from"./router-BXL9ASSk.js";import{R as O}from"./RichTextEditor-Bs1LaLNe.js";import"./vendor-BNcAc9ko.js";import"./Editor-qH2SyrCb.js";/* empty css                         */(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};r.SENTRY_RELEASE={id:"[email protected]"}}catch{}})();try{(function(){var r=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},c=new r.Error().stack;c&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[c]="185ab2bc-5f61-49a1-af8c-3bd46c4125cc",r._sentryDebugIdIdentifier="sentry-dbid-185ab2bc-5f61-49a1-af8c-3bd46c4125cc")})()}catch{}const l="/api/v1/admin",d=()=>({Authorization:`Bearer ${localStorage.getItem("auth_token")}`,Accept:"application/json","Content-Type":"application/json"}),oe=()=>{const[r,c]=i.useState([]),[F,S]=i.useState([]),[M,w]=i.useState([]),[N,_]=i.useState(!0),[h,m]=i.useState(null),[v,k]=i.useState(""),[T,z]=i.useState(""),[a,p]=i.useState(null),[R,o]=i.useState(""),[g,C]=i.useState(null),[E,y]=i.useState(null),[$,I]=i.useState(""),[W,D]=i.useState(""),[b,H]=i.useState(!1),B=async e=>{if(window.confirm("לשלוח מייל לכל חותמי העצומה? פעולה זו תיצור קמפיין שיישלח לכולם.")){C(e);try{const n=await fetch(`${l}/petition-updates/${e}/send-campaign`,{method:"POST",headers:d()}),s=await n.json();n.ok?(o("הקמפיין נוצר בהצלחה! ניתן לנהל אותו בממשק הקמפיינים המתוזמנים."),x(),f()):o(s.error||"שגיאה ביצירת הקמפיין")}catch{o("שגיאה בתקשורת עם השרת")}finally{C(null)}}},[P,J]=i.useState(void 0);i.useEffect(()=>{const n=new URLSearchParams(window.location.search).get("update_id");n&&J(parseInt(n,10))},[]);const x=i.useCallback(async()=>{_(!0);try{const e=await fetch(`${l}/petition-updates/pending`,{headers:d()});if(!e.ok)throw new Error(`HTTP ${e.status}`);const n=await e.json();c(n.updates||[])}catch{o("שגיאה בטעינת עדכונים"),c([])}finally{_(!1)}},[]),f=i.useCallback(async()=>{try{const e=await fetch(`${l}/petition-updates/approved`,{headers:d()});if(!e.ok)throw new Error(`HTTP ${e.status}`);const n=await e.json();S(n.updates||[])}catch{S([])}},[]),u=i.useCallback(async()=>{try{const e=await fetch(`${l}/petition-updates/rejected`,{headers:d()});if(!e.ok)throw new Error(`HTTP ${e.status}`);const n=await e.json();w(n.updates||[])}catch{w([])}},[]);i.useEffect(()=>{x(),f(),u()},[x,f,u]);const Y=e=>{m(e.update_id),k(e.title),z(e.content)},L=async e=>{p(e.update_id);try{const n=await fetch(`${l}/petition-updates/${e.update_id}/approve`,{method:"POST",headers:d(),body:JSON.stringify({title:h===e.update_id?v:e.title,content:h===e.update_id?T:e.content})});if(!n.ok)throw new Error(`HTTP ${n.status}`);o("העדכון אושר בהצלחה"),m(null),x(),f()}catch{o("שגיאה באישור העדכון")}finally{p(null)}},q=async e=>{if(window.confirm("לדחות עדכון זה?")){p(e);try{const n=await fetch(`${l}/petition-updates/${e}/reject`,{method:"POST",headers:d()});if(!n.ok)throw new Error(`HTTP ${n.status}`);o("העדכון נדחה"),x(),u()}catch{o("שגיאה בדחיית העדכון")}finally{p(null)}}},G=async e=>{if(window.confirm("להחזיר את העדכון לתור ההמתנה?")){p(e);try{const n=await fetch(`${l}/petition-updates/${e}/restore`,{method:"POST",headers:d()});if(!n.ok)throw new Error(`HTTP ${n.status}`);o("העדכון הוחזר לתור ההמתנה"),x(),u()}catch{o("שגיאה בהחזרת העדכון")}finally{p(null)}}},K=e=>{y(e.update_id),I(e.title),D(e.content)},Q=async e=>{H(!0);try{const n=await fetch(`/api/v1/petitions/${e.petition_id}/updates/${e.update_id}`,{method:"PUT",headers:d(),body:JSON.stringify({title:$,content:W})}),s=await n.json();if(!n.ok||!s.success){o(s.message||"שגיאה בשמירת העדכון");return}const j=s.synced_campaigns||[];o(j.length>0?`התוכן נשמר. עודכן גם ב-${j.length} קמפיין/ים שטרם סיימו שליחה (#${j.map(V=>V.id).join(", #")}).`:"התוכן נשמר. אין קמפיין פעיל לסנכרון — השינוי מופיע באתר בלבד."),y(null),f()}catch{o("שגיאה בתקשורת עם השרת")}finally{H(!1)}},U=e=>e.status==="rejected"?e.updated_at:e.approved_at||e.updated_at,A=[...F,...M].sort((e,n)=>
1new Date(U(n)||0).getTime()-new Date(U(e)||0).getTime());return N?t.jsx("div",{style:{padding:"24px",textAlign:"right",direction:"rtl"},children:"טוען..."}):t.jsxs("div",{style:{padding:"16px",direction:"rtl",maxWidth:"900px",margin:"0 auto"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:"8px",marginBottom:"16px"},children:[t.jsx("h2",{style:{fontSize:"1.2rem",fontWeight:"bold"},children:"עדכוני עצומות ממתינים לאישור"}),t.jsx("a",{href:"/admin/main",style:{fontSize:"0.85rem",border:"1px solid #cbd5e0",borderRadius:"6px",padding:"6px 14px",textDecoration:"none",color:"#4a5568"},children:"→ חזרה לאדמין"})]}),R&&t.jsxs("div",{style:{background:"#f0fff4",border:"1px solid #9ae6b4",borderRadius:"6px",padding:"10px 14px",marginBottom:"16px",color:"#276749"},children:[R,t.jsx("button",{onClick:()=>o(""),style:{marginRight:"12px",background:"none",border:"none",cursor:"pointer",color:"#276749"},children:"✕"})]}),r.length===0&&t.jsx("p",{style:{color:"#718096"},children:"אין עדכונים ממתינים לאישור"}),r.map(e=>t.jsxs("div",{style:{background:e.update_id===P?"#fffbeb":"#fff",border:e.update_id===P?"2px solid #f6ad55":"1px solid #e2e8f0",borderRadius:"8px",padding:"16px",marginBottom:"16px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",flexWrap:"wrap",gap:"8px",marginBottom:"10px"},children:[t.jsxs("div",{children:[e.petition?.slug?t.jsx("a",{href:`/sign/${e.petition.slug}`,target:"_blank",rel:"noopener noreferrer",style:{fontWeight:"bold",fontSize:"0.95rem",color:"#2b6cb0",textDecoration:"none"},title:"פתח את העצומה בכרטיסייה חדשה",children:e.petition.title}):t.jsx("span",{style:{fontWeight:"bold",fontSize:"0.95rem"},children:e.petition?.title||"עצומה #"+e.petition_id}),t.jsxs("span",{style:{color:"#718096",fontSize:"0.82rem",marginRight:"10px"},children:[e.user?.name," (",e.user?.email,")"]})]}),t.jsx("span",{style:{color:"#a0aec0",fontSize:"0.8rem"},children:new Date(e.created_at).toLocaleDateString("he-IL")})]}),h===e.update_id?t.jsxs("div",{children:[t.jsx("input",{value:v,onChange:n=>k(n.target.value),style:{width:"100%",border:"1px solid #cbd5e0",borderRadius:"4px",padding:"8px",marginBottom:"8px",direction:"rtl",fontSize:"0.95rem",boxSizing:"border-box"},placeholder:"כותרת"}),t.jsx(O,{language:"he",value:T,onChange:n=>z(n),height:250})]}):t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:600,marginBottom:"6px"},children:e.title}),t.jsx("div",{style:{color:"#4a5568",fontSize:"0.9rem"},dangerouslySetInnerHTML:{__html:e.content}})]}),t.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"14px",flexWrap:"wrap"},children:h===e.update_id?t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>L(e),disabled:a===e.update_id,style:{background:"#38a169",color:"white",border:"none",borderRadius:"6px",padding:"8px 18px",cursor:"pointer",fontWeight:"bold",fontSize:"0.9rem"},children:a===e.update_id?"...":"אשר עם עריכה"}),t.jsx("button",{onClick:()=>m(null),style:{background:"#e2e8f0",color:"#4a5568",border:"none",borderRadius:"6px",padding:"8px 18px",cursor:"pointer",fontSize:"0.9rem"},children:"ביטול"})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>L(e),disabled:a===e.update_id,style:{background:"#38a169",color:"white",border:"none",borderRadius:"6px",padding:"8px 18px",cursor:"pointer",fontWeight:"bold",fontSize:"0.9rem"},children:a===e.update_id?"...":"✓ אשר"}),t.jsx("button",{onClick:()=>Y(e),style:{background:"#4267B2",color:"white",border:"none",borderRadius:"6px",padding:"8px 18px",cursor:"pointer",fontSize:"0.9rem"},children:"✎ ערוך ואשר"}),t.jsx("button",{onClick:()=>q(e.update_id),disabled:a===e.update_id,style:{background:"#fff",color:"#e53e3e",border:"1px solid #e53e3e",borderRadius:"6px",padding:"8px 18px",cursor:"pointer",fontSize:"0.9rem"},children:"✕ דחה"}),t.jsx("button",{onClick:()=>B(e.update_id),disabled:g===e.update_id||!!e.emailed_to_signers,title:e.emailed_to_signers?"מייל כבר נשלח לחותמים":"שלח מייל לכל חותמי העצומה",style:{background:e.emailed_to_signers?"#e2e8f0":"#2b6cb0",color:e.emailed_to_signers?"#718096":"white",border:"none",borderRadius:"6px",padding:"8px 18px",cursor:e.emailed_to_signers?"default":"pointer",fontSize:"0.9rem"},children:g===e.update_id?"...":e.emailed_to_signers?"✉ נשלח לחותמים":"✉ שלח לחותמים"})]})})]},e.update_id)),A.length>0&&t.jsxs("div",{style:{marginTop:"32px"},children:[t.jsx("hr",{style:{border:"none",borderTop:"1px solid #e2e8f0",margin:"0 0 16px"}}),t.jsx("h2",{style:{fontSize:"1.1rem",fontWeight:"bold",marginBottom:"14px",color:"#2d3748"},children:"העדכונים האחרונים"}),A.map(e=>{const n=e.status==="rejected";return t.jsxs("div",{style:{background:"#fff",border:"1px solid #e2e8f0",borderRight:`3px solid ${n?"#e53e3e":"#38a169"}`,borderRadius:"8px",padding:"14px 16px",marginBottom:"12px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",flexWrap:"wrap",gap:"8px",marginBottom:"8px"},children:[t.jsxs("div",{children:[e.petition?.slug?t.jsx("a",{href:`/sign/${e.petition.slug}`,target:"_blank",rel:"noopener noreferrer",style:{fontWeight:"bold",fontSize:"0.92rem",color:"#2b6cb0",textDecoration:"none"},title:"פתח את העצומה בכרטיסייה חדשה",children:e.petition.title}):t.jsx("span",{style:{fontWeight:"bold",fontSize:"0.92rem"}
1,children:e.petition?.title||"עצומה #"+e.petition_id}),t.jsx("span",{style:{color:"#718096",fontSize:"0.8rem",marginRight:"10px"},children:e.user?.name})]}),n?t.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center",flexWrap:"wrap"},children:[t.jsxs("span",{style:{color:"#e53e3e",fontSize:"0.78rem",whiteSpace:"nowrap"},children:["✗ נדחה ",e.updated_at?new Date(e.updated_at).toLocaleDateString("he-IL"):""]}),t.jsx("button",{onClick:()=>G(e.update_id),disabled:a===e.update_id,style:{background:"#fff",color:"#4a5568",border:"1px solid #cbd5e0",borderRadius:"4px",padding:"3px 10px",cursor:"pointer",fontSize:"0.75rem"},children:a===e.update_id?"...":"↩ החזר להמתנה"})]}):t.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center",flexWrap:"wrap"},children:[t.jsxs("span",{style:{color:"#38a169",fontSize:"0.78rem",whiteSpace:"nowrap"},children:["✓ אושר ",e.approved_at?new Date(e.approved_at).toLocaleDateString("he-IL"):""]}),E!==e.update_id&&t.jsx("button",{onClick:()=>K(e),style:{background:"#fff",color:"#dd6b20",border:"1px solid #f6ad55",borderRadius:"4px",padding:"3px 10px",cursor:"pointer",fontSize:"0.75rem"},children:"✏️ ערוך תוכן"}),e.emailed_to_signers?t.jsx("span",{style:{color:"#718096",fontSize:"0.75rem",background:"#e2e8f0",borderRadius:"4px",padding:"2px 8px"},children:"✉ נשלח לחותמים"}):t.jsx("button",{onClick:()=>B(e.update_id),disabled:g===e.update_id,style:{background:"#2b6cb0",color:"white",border:"none",borderRadius:"4px",padding:"3px 10px",cursor:"pointer",fontSize:"0.75rem"},children:g===e.update_id?"...":"✉ שלח לחותמים"})]})]}),E===e.update_id?t.jsxs("div",{children:[t.jsx("input",{value:$,onChange:s=>I(s.target.value),style:{width:"100%",border:"1px solid #cbd5e0",borderRadius:"4px",padding:"8px",marginBottom:"8px",direction:"rtl",fontSize:"0.95rem",boxSizing:"border-box"},placeholder:"כותרת"}),t.jsx(O,{language:"he",value:W,onChange:s=>D(s),height:300}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"10px",flexWrap:"wrap"},children:[t.jsx("button",{onClick:()=>Q(e),disabled:b,style:{background:"#dd6b20",color:"white",border:"none",borderRadius:"6px",padding:"8px 18px",cursor:b?"default":"pointer",fontWeight:"bold",fontSize:"0.9rem"},children:b?"...":"💾 שמור שינויים"}),t.jsx("button",{onClick:()=>y(null),disabled:b,style:{background:"#e2e8f0",color:"#4a5568",border:"none",borderRadius:"6px",padding:"8px 18px",cursor:"pointer",fontSize:"0.9rem"},children:"ביטול"}),t.jsx("span",{style:{color:"#718096",fontSize:"0.78rem",alignSelf:"center"},children:'הסטטוס נשאר "אושר". קמפיין שטרם סיים שליחה יעודכן אוטומטית.'})]})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{fontWeight:600,marginBottom:"4px",fontSize:"0.9rem"},children:e.title}),t.jsx("div",{style:{color:"#4a5568",fontSize:"0.88rem"},dangerouslySetInnerHTML:{__html:e.content}})]})]},e.update_id)})]})]})};export{oe as default};
2//# sourceMappingURL=AdminPetitionUpdates-DB9qioQf.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.