PageSourceSearch

https://blacksheepbi.com/assets/AutomationSettings-CYbF_B56.js

js blacksheepbi.com collected 2026-09-30 08:26:50 UTC 5,574 bytes, 1 lines download raw bytes

1import{r as i,j as e}from"./ui-CPW3-RCR.js";import{a as O,aD as q,y as u,z as f,E as j,az as g,J as v,aa as J,I as U,p as X,T as Y,B as $,L as F,ao as G,k as K,s as N,d as n}from"./index-BraPXa8T.js";import{S as o}from"./skeleton-BjAb4vs7.js";import{F as Q}from"./supabase-B2z4OhLQ.js";import"./charts-DCB9_QAo.js";import"./vendor-CIXof4MH.js";const R="copywriter_monthly",D="נתח את הנתונים המספריים של הקמפיינים הממומנים של לקוח X בחודש האחרון. התייחס לביצועי הקריאייטיב והקופי, זהה מסרים שעבדו ומסרים שנכשלו, והצע המלצות קופי מעשיות לחודש הבא.";function te(){const{clients:y,loading:B}=O(),[z,C]=i.useState(!0),[m,b]=i.useState(!1),[d,w]=i.useState(!1),[_,S]=i.useState(null),[x,A]=i.useState("[email protected]"),[h,E]=i.useState([]),[T,k]=i.useState(D),P=i.useMemo(()=>[...y].sort((a,t)=>a.name.localeCompare(t.name,"he")),[y]);i.useEffect(()=>{let a=!1;return(async()=>{C(!0);const{data:s,error:r}=await N.from("automation_configs").select("id, recipient_email, active_clients, ai_prompt").eq("report_type",R).maybeSingle();a||(r?n.error("טעינת ההגדרות נכשלה - "+r.message):s&&(S(s.id),A(s.recipient_email||""),E(Array.isArray(s.active_clients)?s.active_clients:[]),k(s.ai_prompt||D)),C(!1))})(),()=>{a=!0}},[]);const H=(a,t)=>{E(s=>t?Array.from(new Set([...s,a])):s.filter(r=>r!==a))},I=async()=>{const a=x.trim();if(!a||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a))return n.error("כתובת אימייל לא תקינה"),!1;b(!0);const{data:t,error:s}=await N.from("automation_configs").upsert({..._?{id:_}:{},report_type:R,recipient_email:a,active_clients:h,ai_prompt:T},{onConflict:"report_type"}).select("id").maybeSingle();return b(!1),s?(n.error("השמירה נכשלה - "+s.message),!1):(t!=null&&t.id&&S(t.id),n.success("ההגדרות נשמרו"),!0)},M=async()=>{if(h.length===0){n.error("יש לבחור לפחות לקוח אחד לפני שליחת דוח טסט");return}const a=x.trim();if(!a||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a)){n.error("כתובת אימייל לא תקינה");return}if(!await I())return;w(!0);const{data:s,error:r}=await N.functions.invoke("copywriter-ai-report",{body:{recipient_email:a}});if(w(!1),r){let c=r.message;if(r instanceof Q)try{const p=await r.context.json();c=(p==null?void 0:p.error)||c}catch{c=await r.context.text().catch(()=>"")||c}n.error("שליחת הדוח נכשלה - "+c);return}if(s!=null&&s.error){n.error("שליחת הדוח נכשלה - "+s.error);return}const L=Array.isArray(s==null?void 0:s.failed)?s.failed.length:0;n.success(`הדוח נשלח אל ${(s==null?void 0:s.recipient)||a} - ${(s==null?void 0:s.clients_processed)??0} לקוחות`+(L>0?` (${L} לקוחות ללא נתונים)`:"")+((s==null?void 0:s.pdf_attached)===!1?" - ללא קובץ PDF":""))},l=z||B;return e.jsxs("div",{dir:"rtl",className:"space-y-5 max-w-4xl",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-bold",children:"הגדרות אוטומציה"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"ניהול דוח הקופירייטינג החודשי המופק על ידי ה-AI"})]})]}),e.jsxs(u,{children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"נמען הדוח"}),e.jsx(g,{children:"כתובת האימייל שאליה יישלח הדוח החודשי"})]}),e.jsx(v,{children:l?e.jsx(o,{className:"h-9 w-full"}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(J,{htmlFor:"recipient-email",children:"אימייל נמען"}),e.jsx(U,{id:"recipient-email",type:"email",dir:"ltr",className:"text-left",value:x,onChange:a=>A(a.target.value),placeholder:"[email protected]"})]})})]}),e.jsxs(u,{children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"לקוחות בדוח"}),e.jsx(g,{children:"בחר אילו לקוחות ייכללו בדוח החודשי"})]}),e.jsx(v,{children:l?e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{className:"h-6 w-1/2"}),e.jsx(o,{className:"h-6 w-1/3"}),e.jsx(o,{className:"h-6 w-2/5"})]}):P.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"לא נמצאו לקוחות זמינים"}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:P.map(a=>e.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 cursor-pointer hover:bg-accent/50",children:[e.jsx(X,{checked:h.includes(a.id),onCheckedChange:t=>H(a.id,t===!0),"aria-label":`כלול את ${a.name} בדוח`}),e.jsx("span",{className:"text-sm",children:a.name})]},a.id))})})]}),e.jsxs(u,{children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"הנחיית ה-AI"}),e.jsx(g,{children:"תבנית ההנחיה שתישלח למודל בעת הפקת הדוח"})]}),e.jsx(v,{children:l?e.jsx(o,{className:"h-40 w-full"}):e.jsx(Y,{value:T,onChange:a=>k(a.target.value),rows:10,className:"min-h-40 leading-relaxed","aria-label":"הנחיית ה-AI לדוח"})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs($,{onClick:I,disabled:l||m||d,children:[m?e.jsx(F,{className:"h-4 w-4 animate-spin"}):e.jsx(G,{className:"h-4 w-4"}),"שמור הגדרות"]}),e.jsxs($,{variant:"outline",onClick:M,disabled:l||m||d,children:[d?e.jsx(F,{className:"h-4 w-4 animate-spin"}):e.jsx(K,{className:"h-4 w-4"}),d?"מפיק ושולח...":"שלח דוח טסט"]})]})]})}export{te 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.