PageSourceSearch

https://app-6295d702.base44.app/assets/EmailsManagement-p5gLsBzN.js

js app-6295d702.base44.app collected 2026-10-03 03:11:43 UTC 27,124 bytes, 54 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Dci_jJno.js","assets/index-D66GGtHU.css"])))=>i.map(i=>d[i]);
2import{c as V,r,j as e,B as n,I as q,aV as we,b as K,f as Ce,u as Te,d as B,m as ee}from"./index-Dci_jJno.js";import{u as ne}from"./useMutation-DOIVzkfi.js";import{C as v,a as k,b as ce,c as Se}from"./card-BebN6SXj.js";import{B as Z}from"./badge-D_hVK-aO.js";import{A as Ee,a as Re}from"./alert-DJqlm7os.js";import{D as he,a as ge,b as ue,c as pe,d as Le}from"./dialog-CbOvNZpN.js";import{L as H}from"./label-fG4cXIBY.js";import{S as Ie}from"./switch-F2tYJD5I.js";import{S as De,a as Me,b as Ae,c as Be,d as He}from"./select-CNTfxrTc.js";import{Z as Ve}from"./zap-C853piMM.js";import{U as ze}from"./user-check-PhIvLyx8.js";import{I as Fe}from"./info-DZKlOuGH.js";import{C as Pe}from"./check-DqTXOUsg.js";import{C as Oe}from"./copy-CIa098fe.js";import{L as de}from"./link-v2HSzc4A.js";import{S as Ue}from"./send-BZPQhOij.js";import{C as Ge}from"./circle-check-big-Thn5nELk.js";import{C as $e}from"./circle-alert-B2baUo0l.js";import{P as oe}from"./plus-CrJLQVlx.js";import{E as qe}from"./eye-Czr7YCSO.js";import{S as Qe}from"./square-pen--U2vZ0Hi.js";import"./index-DL5p_O24.js";import"./index-2pNUjjD_.js";import"./index-qpB6SCQY.js";/**
3 * @license lucide-react v0.475.0 - ISC
4 *
5 * This source code is licensed under the ISC license.
6 * See the LICENSE file in the root directory of this source tree.
7 */const Ye=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],Ke=V("Bold",Ye);/**
8 * @license lucide-react v0.475.0 - ISC
9 *
10 * This source code is licensed under the ISC license.
11 * See the LICENSE file in the root directory of this source tree.
12 */const Ze=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],We=V("Italic",Ze);/**
13 * @license lucide-react v0.475.0 - ISC
14 *
15 * This source code is licensed under the ISC license.
16 * See the LICENSE file in the root directory of this source tree.
17 */const Je=[["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]],Xe=V("Redo",Je);/**
18 * @license lucide-react v0.475.0 - ISC
19 *
20 * This source code is licensed under the ISC license.
21 * See the LICENSE file in the root directory of this source tree.
22 */const es=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],ss=V("Underline",es);/**
23 * @license lucide-react v0.475.0 - ISC
24 *
25 * This source code is licensed under the ISC license.
26 * See the LICENSE file in the root directory of this source tree.
27 */const as=[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]],ts=V("Undo",as);function rs({open:u,onOpenChange:x,template:s,variables:w=[],triggerInfo:l=null,availableTriggers:m=[],triggerLabels:b={},triggerInfoMap:I={},triggerVariablesMap:h={},triggersWithDaysBefore:d=[],onSave:j}){const[p,E]=r.useState(""),[C,f]=r.useState(""),[z,F]=r.useState(""),[P,O]=r.useState(!0),[_,T]=r.useState(""),[U,t]=r.useState(7),[y,g]=r.useState(null),[D,se]=r.useState(!1),N=r.useRef(null),W=r.useRef(!1),[ae,G]=r.useState(null),[te,re]=r.useState(""),J=!(s!=null&&s.id)&&!(s!=null&&s.trigger_type),R=(s==null?void 0:s.trigger_type)||_,X=l||(R?I[R]:null),ie=w.length>0?w:R?h[R]||[]:[],le=(s==null?void 0:s.trigger_name)||(R?b[R]:"");r.useEffect(()=>{u&&s&&(E(s.subject||""),f(s.body_html||""),F(s.cc_email||""),O(s.is_active!==!1),T(s.trigger_type||""),t(s.reminder_days_before??7),W.current=!1)},[u,s]);const ye=(s==null?void 0:s.trigger_type)||_,be=d.includes(ye);r.useEffect(()=>{if(!N.current||W.current||!u)return;const a=N.current,i=setTimeout(()=>{const o=a.contentDocument;o&&(o.open(),o.write(`<!DOCTYPE html>
28<html dir="rtl">
29<head>
30  <meta charset="utf-8">
31  <style>
32    body {
33      font-family: Arial, Helvetica, sans-serif;
34      margin: 0;
35      padding: 16px;
36      direction: rtl;
37      background: #f9fafb;
38      min-height: 100%;
39    }
40    body:focus {
41      outline: none;
42    }
43    [contenteditable]:focus {
44      outline: 2px solid #3b82f6;
45      outline-offset: 2px;
46      border-radius: 4px;
47    }
48    ::selection {
49      background: #bfdbfe;
50    }
51  </style>
52</head>
53<body contenteditable="true">${C}</body>
54</html>`),o.close(),o.body.addEventListener("input",()=>{f(o.body.innerHTML)}),o.body.addEventListener("click",S=>{S.preventDefault();const L=S.target.closest("a");L?(S.stopPropagation(),G(L),re(L.getAttribute("href")||"")):G(null)}),W.current=!0)},100);return()=>clearTimeout(i)},[u,C]);const M=r.useCallback((a,c=null)=>{var o;const i=(o=N.current)==null?void 0:o.contentDocument;i&&(i.body.focus(),i.execCommand(a,!1,c),f(i.body.innerHTML))},[]),je=r.useCallback(()=>{var i;const a=(i=N.current)==null?void 0:i.contentDocument;if(!a)return;const c=prompt("הזן כתובת URL:");c&&(a.body.focus(),a.execCommand("createLink",!1,c),f(a.body.innerHTML))},[]),fe=r.useCallback(a=>{var i;const c=(i=N.current)==null?void 0:i.contentDocument;c&&(c.body.focus(),c.execCommand("insertText",!1,a),f(c.body.innerHTML))},[]),_e=async()=>{var L;se(!0);const a=(L=N.current)==null?void 0:L.contentDocument,c=a?a.body.innerHTML:C,i=(s==null?void 0:s.trigger_type)||_,o=(s==null?void 0:s.trigger_name)||b[_]||"",S={trigger_type:i,trigger_name:o,subject:p,body_html:c,cc_email:z,is_active:P};if(d.includes(i)&&(S.reminder_days_before=Number(U)||7),i==="campaign_expiring_reminder"&&(s!=null&&s.id)&&(s==null?void 0:s.reminder_days_before)!==S.reminder_days_before)try{const{base44:$}=await we(async()=>{const{base44:A}=await import("./index-Dci_jJno.js").then(ke=>ke.aY);return{base44:A}},__vite__mapDeps([0,1])),ve=await $.entities.Campaign.filter({});await Promise.all(ve.filter(A=>A.last_reminder_sent_for_end_date).map(A=>$.entities.Campaign.update(A.id,{last_reminder_sent_for_end_date:null})))}catch($){console.error("Failed to reset reminder tracking on campaigns",$)}await j(S),se(!1)},Ne=a=>{navigator.clipboard.writeText(a),g(a),setTimeout(()=>g(null),2e3)};return e.jsx(he,{open:u,onOpenChange:x,children:e.jsxs(ge,{className:"max-w-5xl max-h-[90vh] overflow-y-auto",dir:"rtl",children:[e.jsxs(ue,{children:[e.jsx(pe,{className:"text-xl font-bold",children:s!=null&&s.id?"עריכת תבנית מייל":"יצירת תבנית מייל"}),le&&!J&&e.jsxs("p",{className:"text-gray-600",children:["טריגר: ",le]})]}),e.jsxs("div",{className:"space-y-4",children:[J&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(H,{htmlFor:"trigger_type",className:"font-medium",children:["בחר טריגר לתבנית ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(De,{value:_,onValueChange:T,children:[e.jsx(Me,{id:"trigger_type",dir:"rtl",children:e.jsx(Ae,{placeholder:"בחר טריגר זמין..."})}),e.jsx(Be,{dir:"rtl",children:m.length===0?e.jsx("div",{className:"px-2 py-3 text-sm text-gray-500 text-center",children:"אין טריגרים זמינים - לכל הטריגרים כבר יש תבניות"}):m.map(a=>e.jsx(He,{value:a,children:b[a]},a))})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"לכל טריגר יכולה להיות רק תבנית אחת. הטריגרים מוגדרים בקוד המערכת ולכן אינם ניתנים לשינוי."})]}),X&&e.jsx(v,{className:"border-purple-200 bg-purple-50",children:e.jsxs(k,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ve,{className:"w-5 h-5 text-purple-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium text-gray-900 mb-1",children:"מתי המייל נשלח?"}),e.jsx("p",{className:"text-sm text-gray-700",children:X.when})]})]}),e.jsxs("div",{className:"flex items-start gap-2 pt-3 border-t border-purple-200",children:[e.jsx(ze,{className:"w-5 h-5 text-purple-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium text-gray-900 mb-1",children:"למי נשלח המייל?"}),e.jsx("p",{className:"text-sm text-gray-700",children:X.recipient})]})]})]})}),e.jsx(v,{className:"border-blue-200 bg-blue-50",children:e.jsxs(k,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[e.jsx(Fe,{className:"w-5 h-5 text-blue-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900",children:"משתנים זמינים"}),e.jsx("p",{className:"text-sm text-gray-600",children:'לחץ להעתקה, או "הכנס" להוספה ישירה לתוכן'})]})]}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:ie.length===0?e.jsx("p",{className:"text-sm text-gray-500 italic",children:"בחר טריגר לראיית המשתנים הזמינים"}):ie.map(a=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs(n,{variant:"outline",size:"sm",onClick:()=>Ne(a.key),className:"gap-1 bg-white",children:[y===a.key?e.jsx(Pe,{className:"w-3 h-3 text-green-600"}):e.jsx(Oe,{className:"w-3 h-3"}),e.jsx("span",{className:"font-mono text-xs",children:a.key}),e.jsxs("span",{className:"text-gray-500",children:["(",a.label,")"]})]}),e.jsx(n,{variant:"ghost",size:"sm",onClick:()=>fe(a.key),className:"text-xs text-blue-600 px-2 h-7",children:"הכנס"})]},a.key))})]})}),be&&e.jsxs("div",{className:"space-y-2 p-4 bg-amber-50 border border-amber-200 rounded-lg",children:[e.jsx(H,{htmlFor:"reminder_days_before",className:"font-medium",children:"כמה ימים לפני תאריך הסיום לשלוח את התזכורת"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q,{id:"reminder_days_before",type:"number",min:"1",max:"365",value:U,onChange:a=>t(a.target.value),className:"w-32"}),e.jsx("span",{className:"text-sm text-gray-600",children:"ימים לפני"})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"ברירת מחדל: 7 ימים. אם תשנה את הערך לאחר ששלחנו תזכורת - המנגנון יתאפס וישלח שוב בהתאם להגדרה החדשה."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{htmlFor:"subject",children:"נושא המייל"}),e.jsx(q,{id:"subject",value:p,onChange:a=>E(a.target.value),placeholder:"הזן את נושא המייל...",dir:"rtl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{htmlFor:"cc_email",children:"העתק מייל (CC)"}),e.jsx(q,{id:"cc_email",type:"email",value:z,onChange:a=>F(a.target.value),placeholder:"כתובת מייל לקבלת העתק (אופציונלי)...",dir:"ltr",className:"text-left"}),e.jsx("p",{className:"text-xs text-gray-500",children:"אם תוכנס כתובת, היא תקבל העתק של כל מייל שיישלח מתבנית זו"})]}),e.jsxs("div",{className:"flex items-center gap-1 p-2 bg-gray-100 rounded-t-lg border border-b-0 border-gray-300",children:[e.jsx(n,{variant:"ghost",size:"sm",onClick:()=>M("bold"),className:"h-8 w-8 p-0",title:"מודגש",children:e.jsx(Ke,{className:"w-4 h-4"})}),e.jsx(n,{variant:"ghost",size:"sm",onClick:()=>M("italic"),className:"h-8 w-8 p-0",title:"נטוי",children:e.jsx(We,{className:"w-4 h-4"})}),e.jsx(n,{variant:"ghost",size:"sm",onClick:()=>M("underline"),className:"h-8 w-8 p-0",title:"קו תחתון",children:e.jsx(ss,{className:"w-4 h-4"})}),e.jsx("div",{className:"w-px h-5 bg-gray-300 mx-1"}),e.jsx(n,{variant:"ghost",size:"sm",onClick:je,className:"h-8 w-8 p-0",title:"הוספת קישור",children:e.jsx(de,{className:"w-4 h-4"})}),e.jsx("div",{className:"w-px h-5 bg-gray-300 mx-1"}),e.jsx(n,{variant:"ghost",size:"sm",onClick:()=>M("undo"),className:"h-8 w-8 p-0",title:"בטל",children:e.jsx(ts,{className:"w-4 h-4"})}),e.jsx(n,{variant:"ghost",size:"sm",onClick:()=>M("redo"),className:"h-8 w-8 p-0",title:"חזור",children:e.jsx(Xe,{className:"w-4 h-4"})}),e.jsx("div",{className:"w-px h-5 bg-gray-300 mx-1"}),e.jsx("span",{className:"text-xs text-gray-500 mr-2",children:"לחץ על הטקסט בתבנית כדי לערוך אותו"})]}),ae&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-amber-50 border border-amber-300 rounded-lg",children:[e.jsx(de,{className:"w-4 h-4 text-amber-600 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-gray-700 flex-shrink-0",children:"קישור:"}),e.jsx(q,{value:te,onChange:a=>re(a.target.value),className:"flex-1 h-8 text-sm",dir:"ltr",placeholder:"https://..."}),e.jsx(n,{size:"sm",className:"h-8 bg-amber-600 hover:bg-amber-700",onClick:()=>{var a,c,i;ae.setAttribute("href",te),f(((i=(c=(a=N.current)==null?void 0:a.contentDocument)==null?void 0:c.body)==null?void 0:i.innerHTML)||C),G(null)},children:"שמור"}),e.jsx(n,{variant:"ghost",size:"sm",className:"h-8",onClick:()=>G(null),children:"ביטול"})]}),e.jsx("div",{className:"border border-gray-300 rounded-b-lg overflow-hidden",children:e.jsx("iframe",{ref:N,className:"w-full border-0",style:{height:"450px"},title:"עריכת תבנית"})}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-lg",children:[e.jsxs("div",{children:[e.jsx(H,{htmlFor:"is_active",className:"font-medium",children:"תבנית פעילה"}),e.jsx("p",{className:"text-sm text-gray-500",children:"כאשר פעילה, מיילים יישלחו בהתאם לטריגר"})]}),e.jsx(Ie,{id:"is_active",checked:P,onCheckedChange:O})]})]}),e.jsxs(Le,{className:"gap-2",children:[e.jsx(n,{variant:"outline",onClick:()=>x(!1),children:"ביטול"}),e.jsx(n,{onClick:_e,disabled:!p||!C||D||J&&!_,className:"bg-blue-600 hover:bg-blue-700",children:D?"שומר...":"שמור תבנית"})]})]})})}function is({open:u,onOpenChange:x,template:s,variables:w=[]}){if(!s)return null;const l={"{{user_name}}":"ישראל ישראלי","{{trip_name}}":"טיול מספר 5 - נחל ערוגות","{{trip_date}}":"15/02/2026"},m=d=>{if(!d)return"";let j=d;return Object.entries(l).forEach(([p,E])=>{j=j.replace(new RegExp(p.replace(/[{}]/g,"\\$&"),"g"),E)}),j},b=m(s.subject),h=`<div dir="rtl" style="text-align: right; font-family: Arial, sans-serif;">${m(s.body_html)}</div>`;return e.jsx(he,{open:u,onOpenChange:x,children:e.jsxs(ge,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",dir:"rtl",children:[e.jsxs(ue,{children:[e.jsxs(pe,{className:"text-xl font-bold flex items-center gap-2",children:[e.jsx(K,{className:"w-5 h-5 text-blue-600"}),"תצוגה מקדימה"]}),e.jsx("p",{className:"text-gray-600",children:s.trigger_name})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{className:"border-gray-200 bg-gray-50",children:e.jsxs(k,{className:"p-4",children:[e.jsx("p",{className:"text-sm text-gray-600 mb-2 font-medium",children:"ערכים לדוגמה:"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:w.map(d=>e.jsxs(Z,{variant:"secondary",className:"text-xs",children:[d.label,": ",l[d.key]]},d.key))})]})}),e.jsxs(v,{className:"border-blue-200",children:[e.jsx(ce,{className:"border-b bg-gray-50 py-3",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-500",children:"נושא:"}),e.jsx("span",{className:"font-medium",children:b})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-500",children:"אל:"}),e.jsx("span",{className:"text-sm",children:"[email protected]"})]})]})}),e.jsx(k,{className:"p-6",children:e.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:h}})})]}),e.jsxs(v,{className:"border-gray-200",children:[e.jsx(ce,{className:"py-3",children:e.jsx(Se,{className:"text-sm font-medium text-gray-700",children:"קוד HTML שיישלח"})}),e.jsx(k,{className:"p-4",children:e.jsx("pre",{className:"text-xs bg-gray-100 p-3 rounded overflow-x-auto whitespace-pre-wrap",dir:"ltr",children:h})})]})]})]})})}const Q={waiting_list_spot_available:"התפנה מקום ברשימת המתנה",public_trip_purchase:"אישור רכישת טיול (גולשים חדשים)",existing_user_trip_purchase:"אישור רכישת טיול (משתמש קיים)",lead_subscription_invite:"הזמנה למערכת אחרי מכירה מ-CRM",trip_reminder:"תזכורת לפני טיול (10 ימים)",campaign_expiring_reminder
54:"תזכורת על קמפיין שעומד להסתיים",guide_monthly_report:"דוח חודשי למדריך (שליחה ידנית)"},me=["campaign_expiring_reminder"],xe={waiting_list_spot_available:{when:"כאשר מתפנה מקום בטיול שמשתמש ממתין לו ברשימת ההמתנה",recipient:"המשתמש הממתין שתורו הגיע ברשימת ההמתנה"},public_trip_purchase:{when:"מיד לאחר רכישת טיול דרך הדף הציבורי על ידי גולש חדש (משתמש שאינו רשום במערכת)",recipient:"הרוכש החדש (לפי כתובת המייל שהוזנה בטופס הרכישה)"},existing_user_trip_purchase:{when:"כאשר משתמש קיים במערכת רוכש טיול בתשלום (טיול שאינו כלול במנוי שלו, או רכישת טיול נוסף)",recipient:"המשתמש הקיים שרכש את הטיול"},lead_subscription_invite:{when:"כאשר ליד ב-CRM מסומן כמכירה והופך למנוי במערכת",recipient:"הלקוח שהפך למנוי (לפי המייל שלו ב-CRM)"},trip_reminder:{when:"10 ימים לפני מועד הטיול (נשלח אוטומטית מדי יום לטיולים העומדים בתנאי)",recipient:"כל המשתתפים הרשומים לטיול"},campaign_expiring_reminder:{when:"מספר ימים שתוגדר לפני תאריך הסיום של כל קמפיין פעיל (ברירת מחדל: 7 ימים). אם משנים את תאריך הסיום או את מועד השליחה לאחר שנשלחה תזכורת - המנגנון מתאפס וישלח שוב.",recipient:"כל המשתמשים המקושרים לקבוצות היעד של הקמפיין שעדיין לא רכשו ועדיין לא רשומים לעונה"},guide_monthly_report:{when:"נשלח ידנית מתוך עמוד פירוט מדריך, בלחיצה על 'שלח דוח במייל' באקורדיון של חודש. צירוף קובץ אקסל עם פירוט הטיולים והשכר.",recipient:"כתובת המייל של המדריך (שדה 'מייל' בכרטיס המדריך)"}},Y={waiting_list_spot_available:[{key:"{{user_name}}",label:"שם המשתמש"},{key:"{{trip_name}}",label:"שם הטיול"},{key:"{{trip_date}}",label:"תאריך הטיול"}],public_trip_purchase:[{key:"{{buyer_name}}",label:"שם הרוכש"},{key:"{{trip_name}}",label:"שם הטיול"},{key:"{{trip_date}}",label:"תאריך הטיול"},{key:"{{trip_time}}",label:"שעת הטיול"},{key:"{{meeting_point}}",label:"נקודת מפגש"},{key:"{{price}}",label:"מחיר"},{key:"{{registration_link}}",label:"קישור להרשמה למערכת"}],existing_user_trip_purchase:[{key:"{{buyer_name}}",label:"שם הרוכש"},{key:"{{trip_name}}",label:"שם הטיול"},{key:"{{trip_date}}",label:"תאריך הטיול"},{key:"{{trip_time}}",label:"שעת הטיול"},{key:"{{meeting_point}}",label:"נקודת מפגש"},{key:"{{price}}",label:"מחיר"},{key:"{{login_link}}",label:"קישור להתחברות למערכת"}],lead_subscription_invite:[{key:"{{buyer_name}}",label:"שם הלקוח"},{key:"{{registration_link}}",label:"קישור להרשמה למערכת"}],trip_reminder:[{key:"{{user_name}}",label:"שם המשתמש"},{key:"{{trip_name}}",label:"שם הטיול"},{key:"{{trip_date}}",label:"תאריך הטיול"},{key:"{{trip_time}}",label:"שעת הטיול"},{key:"{{meeting_point}}",label:"נקודת מפגש"},{key:"{{meeting_point_link}}",label:"לינק לנקודת מפגש"},{key:"{{trip_type}}",label:"סוג הטיול"},{key:"{{system_link}}",label:"קישור למערכת"}],campaign_expiring_reminder:[{key:"{{user_name}}",label:"שם המשתמש"},{key:"{{campaign_title}}",label:"כותרת הקמפיין"},{key:"{{campaign_description}}",label:"תיאור הקמפיין"},{key:"{{campaign_price}}",label:"מחיר"},{key:"{{campaign_max_payments}}",label:"מספר תשלומים מקסימלי"},{key:"{{campaign_end_date}}",label:"תאריך סיום הקמפיין"},{key:"{{days_left}}",label:"כמה ימים נותרו"},{key:"{{season_label}}",label:"תיאור העונה"},{key:"{{system_link}}",label:"קישור למערכת"}],guide_monthly_report:[{key:"{{guide_name}}",label:"שם המדריך"},{key:"{{month_name}}",label:"שם החודש"},{key:"{{year}}",label:"שנה"}]};
54function Ls(){const[u,x]=r.useState(!1),[s,w]=r.useState(!1),[l,m]=r.useState(null),[b,I]=r.useState(!1),[h,d]=r.useState(null),j=Ce(),{data:p=[],isLoading:E}=Te({queryKey:["email-templates"],queryFn:()=>B.entities.EmailTemplate.list()}),C=ne({mutationFn:t=>B.entities.EmailTemplate.create(t),onSuccess:()=>{j.invalidateQueries({queryKey:["email-templates"]})}}),f=ne({mutationFn:({id:t,data:y})=>B.entities.EmailTemplate.update(t,y),onSuccess:()=>{j.invalidateQueries({queryKey:["email-templates"]})}}),z=t=>{m(t),x(!0)},F=t=>{m(t),w(!0)},P=t=>{m({trigger_type:t,trigger_name:Q[t],subject:"",body_html:"",is_active:!0,reminder_days_before:me.includes(t)?7:void 0}),x(!0)},O=async t=>{l!=null&&l.id?await f.mutateAsync({id:l.id,data:t}):await C.mutateAsync(t),x(!1),m(null)},_=p.map(t=>t.trigger_type),T=Object.keys(Q).filter(t=>!_.includes(t)),U=async()=>{var t,y;I(!0),d(null);try{const g=await B.auth.me(),D=await B.functions.invoke("sendEmail",{to:g.email,subject:"בדיקת חיבור מייל - על השביל",body_html:"<h2>הבדיקה הצליחה! 🎉</h2><p>מייל זה נשלח דרך Resend.</p><p>אם אתה רואה הודעה זו, החיבור תקין.</p>"});(t=D.data)!=null&&t.success?d({success:!0,message:`מייל בדיקה נשלח ל-${g.email}`}):d({success:!1,message:((y=D.data)==null?void 0:y.error)||"שגיאה בשליחה"})}catch(g){d({success:!1,message:g.message||"שגיאה בשליחה"})}finally{I(!1)}};return e.jsxs("div",{className:"min-h-screen p-4 md:p-8 bg-gray-50",dir:"rtl",children:[e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsx(ee.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},className:"mb-8",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900 mb-2",children:"ניהול מיילים"}),e.jsx("p",{className:"text-gray-600",children:"הגדרת תבניות מייל ושליחה דרך Resend"})]}),e.jsxs(n,{onClick:U,variant:"outline",className:"gap-2",disabled:b,children:[e.jsx(Ue,{className:"w-4 h-4"}),b?"שולח...":"שלח מייל בדיקה"]})]})}),e.jsxs(ee.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:"mb-8 space-y-3",children:[e.jsx(v,{className:"border-2 border-green-200 bg-green-50",children:e.jsx(k,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-green-100 rounded-full flex items-center justify-center",children:e.jsx(K,{className:"w-5 h-5 text-green-700"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900",children:"Resend - שרת מיילים ראשי"}),e.jsx("p",{className:"text-sm text-gray-600",children:"מיילים נשלחים דרך Resend API ישירות מהמערכת"})]}),e.jsx(Z,{className:"bg-green-500 text-white mr-auto",children:"מחובר"})]})})}),h&&e.jsxs(Ee,{className:h.success?"border-green-200 bg-green-50":"border-red-200 bg-red-50",children:[h.success?e.jsx(Ge,{className:"w-4 h-4 text-green-600"}):e.jsx($e,{className:"w-4 h-4 text-red-600"}),e.jsx(Re,{className:h.success?"text-green-800":"text-red-800",children:h.message})]})]}),e.jsxs(ee.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2},children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("h2",{className:"text-xl font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(K,{className:"w-5 h-5 text-blue-600"}),"תבניות מייל"]}),T.length>0&&e.jsxs(n,{onClick:()=>{m({trigger_type:"",trigger_name:"",subject:"",body_html:"",is_active:!0}),x(!0)},className:"gap-2 bg-blue-600 hover:bg-blue-700",children:[e.jsx(oe,{className:"w-4 h-4"}),"תבנית חדשה"]})]}),E?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})}):e.jsxs("div",{className:"space-y-4",children:[p.map(t=>{var y;return e.jsx(v,{className:"hover:shadow-md transition-shadow",children:e.jsx(k,{className:"p-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:t.trigger_name}),e.jsx(Z,{className:t.is_active?"bg-green-100 text-green-700":"bg-gray-100 text-gray-600",children:t.is_active?"פעיל":"לא פעיל"})]}),e.jsxs("p",{className:"text-gray-600 mb-2",children:[e.jsx("span",{className:"font-medium",children:"נושא:"})," ",t.subject||"לא הוגדר"]}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:(y=Y[t.trigger_type])==null?void 0:y.map(g=>e.jsx(Z,{variant:"outline",className:"text-xs",children:g.label},g.key))})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(n,{variant:"outline",size:"sm",onClick:()=>
54F(t),children:[e.jsx(qe,{className:"w-4 h-4 ml-1"}),"תצוגה מקדימה"]}),e.jsxs(n,{size:"sm",onClick:()=>z(t),className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(Qe,{className:"w-4 h-4 ml-1"}),"עריכה"]})]})]})})},t.id)}),T.map(t=>e.jsx(v,{className:"border-dashed border-2 border-gray-300 hover:border-blue-400 transition-colors",children:e.jsx(k,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium text-gray-700",children:Q[t]}),e.jsx("p",{className:"text-sm text-gray-500",children:"לא הוגדרה תבנית"})]}),e.jsxs(n,{variant:"outline",onClick:()=>P(t),className:"gap-2",children:[e.jsx(oe,{className:"w-4 h-4"}),"צור תבנית"]})]})})},t)),p.length===0&&T.length===0&&e.jsxs("div",{className:"text-center py-12 bg-gray-100 rounded-lg",children:[e.jsx(K,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500",children:"אין תבניות מייל"})]})]})]})]}),e.jsx(rs,{open:u,onOpenChange:x,template:l,variables:l?Y[l.trigger_type]:[],triggerInfo:l?xe[l.trigger_type]:null,availableTriggers:T,triggerLabels:Q,triggerInfoMap:xe,triggerVariablesMap:Y,triggersWithDaysBefore:me,onSave:O}),e.jsx(is,{open:s,onOpenChange:w,template:l,variables:l?Y[l.trigger_type]:[]})]})}export{Ls 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.