PageSourceSearch

https://app.xlift.ai/assets/TemplatesPage-DC6yLju8.js

js xlift.ai collected 2026-10-05 13:20:18 UTC 5,864 bytes, 1 lines download raw bytes

1import{ai as D,o as u,A as q,al as f,a4 as w,U as o,a5 as I,j as e,C as b,G as l,$ as N,X as c,T as g,at as K,aL as Q,D as P,E,Z as R,L as M}from"./index-dE8a1mPK.js";import{E as A}from"./EmptyState-BpgfYYCq.js";import{E as L}from"./ErrorState-gVNyx0--.js";import{A as $}from"./AiWriteButton-BOd6FUXb.js";import{u as H}from"./useConfirm-4D74KrCi.js";import{I as k}from"./IconPlus-B47PY1MC.js";import{C as h}from"./Code-YtMEZkZ5.js";import{I as U}from"./IconEdit-yVOCeDQ1.js";import{I as W}from"./IconCopy-B63sUmw8.js";import{I as G}from"./IconTrash-DIXYcrq7.js";import{S as O}from"./Select-DebRlW67.js";import{T as V}from"./Textarea-BtbUvWWM.js";import{I as X}from"./IconWand-C0msnEB9.js";import"./OptionsDropdown-wonErrz5.js";import"./CheckIcon-DkMc45y2.js";import"./get-env-uyVen0u2.js";function ue(){const r=D(),{confirm:x,ConfirmDialog:v}=H(),[i,a]=u.useState(null),{data:n,isLoading:d,error:j}=q({queryKey:["templates"],queryFn:()=>o.listTemplates()}),m=f({mutationFn:t=>o.removeTemplate(t),onSuccess:()=>r.invalidateQueries({queryKey:["templates"]}),onError:t=>w(t)}),y=f({mutationFn:t=>o.cloneTemplate(t.id),onSuccess:()=>{I("Duplicated"),r.invalidateQueries({queryKey:["templates"]})},onError:t=>w(t)});return e.jsxs(b,{gap:"md",children:[e.jsxs(l,{justify:"space-between",children:[e.jsx(N,{order:2,children:"Templates"}),e.jsx(c,{leftSection:e.jsx(k,{size:16}),onClick:()=>a("new"),children:"New template"})]}),e.jsxs(g,{c:"dimmed",size:"sm",children:["Spintax with ",e.jsx(h,{children:"{a|b|c}"})," picks one randomly per send. Variables like"," ",e.jsx(h,{children:"{{handle}}"})," get substituted from each prospect's row."]}),i&&e.jsx(Z,{templateId:i==="new"?null:i,onClose:()=>a(null)}),d&&e.jsx(K,{count:3,h:120}),j&&e.jsx(L,{error:j,onRetry:()=>r.invalidateQueries({queryKey:["templates"]})}),n&&n.templates.length===0&&e.jsx(A,{icon:e.jsx(Q,{size:32,stroke:1.5,color:"var(--mantine-color-gray-6)"}),title:"No templates yet",description:"Templates are reusable message bodies with {{handle}} / {{name}} / brand variables. DM Outreach + Auto Engage campaigns pick one to personalize at send time.",cta:{label:"New template",icon:e.jsx(k,{size:14}),onClick:()=>a("new")}}),n&&n.templates.map(t=>{var p;return e.jsx(P,{withBorder:!0,children:e.jsxs(l,{justify:"space-between",align:"flex-start",wrap:"wrap",gap:"sm",children:[e.jsxs(b,{gap:4,style:{flex:"1 1 280px",minWidth:0},children:[e.jsxs(l,{gap:"xs",wrap:"wrap",children:[e.jsx(g,{fw:600,children:t.name}),e.jsx(E,{variant:"light",children:t.type}),((p=t.variables)==null?void 0:p.length)>0&&e.jsxs(E,{variant:"dot",color:"cyan",children:["vars: ",t.variables.join(", ")]})]}),e.jsx(h,{block:!0,style:{fontSize:12,whiteSpace:"pre-wrap"},children:t.body})]}),e.jsxs(l,{gap:"xs",wrap:"wrap",children:[e.jsx(c,{size:"xs",variant:"subtle",leftSection:e.jsx(U,{size:14}),onClick:()=>a(t.id),children:"Edit"}),e.jsx(c,{size:"xs",variant:"subtle",leftSection:e.jsx(W,{size:14}),onClick:()=>y.mutate(t),loading:y.isPending,children:"Duplicate"}),e.jsx(c,{size:"xs",variant:"subtle",color:"red",leftSection:e.jsx(G,{size:14}),onClick:async()=>{await x({title:`Delete template "${t.name}"?`,body:"Soft-archived. Campaigns that already snapshotted this template at materialization time keep running.",confirmLabel:"Delete"})&&m.mutate(t.id)},children:"Delete"})]})]})},t.id)}),e.jsx(v,{})]})}function Z({templateId:r,onClose:x}){var z;const v=D(),i=!r,{data:a}=q({queryKey:["template",r],queryFn:()=>o.getTemplate(r),enabled:!!r}),n=(a==null?void 0:a.template)||{type:"dm",name:"",body:""},[d,j]=u.useState(n.type),[m,y]=u.useState(n.name),[t,p]=u.useState(n.body),[S,B]=u.useState([]);u.useEffect(()=>{var s;(s=a==null?void 0:a.template)!=null&&s.id&&(j(a.template.type),y(a.template.name),p(a.template.body))},[(z=a==null?void 0:a.template)==null?void 0:z.id]);const T=f({mutationFn:()=>i?o.createTemplate({type:d,name:m,body:t}):o.patchTemplate(r,{name:m,body:t}),onSuccess:()=>{v.invalidateQueries({queryKey:["templates"]}),I(i?"Template created":"Saved"),x()},onError:s=>w(s)}),C=f({mutationFn:()=>o.previewTemplate({body:t,count:5,vars:{handle:"demo_user",name:"Demo User"}}),onSuccess:s=>B(s.samples||[]),onError:s=>w(s)});return e.jsx(R,{opened:!0,onClose:x,title:i?"New template":"Edit template",size:"lg",children:e.jsxs(b,{gap:"sm",children:[e.jsxs(l,{grow:!0,children:[e.jsx(O,{label:"Type",value:d,onChange:s=>j(s),data:[{value:"dm",label:"DM (direct message)"},{value:"post",label:"Post (tweet)"},{value:"reply",label:"Reply"}],disabled:!i}),e.jsx(M,{label:"Name",value:m,onChange:s=>y(s.currentTarget.value)})]}),e.jsxs("div",{children:[e.jsxs(l,{justify:"space-between",align:"flex-end",mb:4,children:[e.jsx(g,{size:"sm",fw:500,children:"Body"}),e.jsx($,{kind:"template-body",context:{purpose:d==="dm"?"cold outreach DM":d==="reply"?"reply to a tweet":"tweet template",variables:["handle","name"]},current:t,onResult:p})]}),e.jsx(V,{description:e.jsxs(e.Fragment,{children:["Use ",e.jsx(h,{children:"{a|b}"})," for spintax and ",e.jsx(h,{children:"{{handle}}"})," for variables."]}),value:t,onChange:s=>p(s.currentTarget.value),minRows:6,autosize:!0,placeholder:"{Hi|Hey|Hello} @{{handle}}, {great|nice|awesome} {post|thread} on…"})]}),e.jsx(l,{children:e.jsx(c,{leftSection:e.jsx(X,{size:14}),variant:"light",onClick:()=>C.mutate(),loading:C.isPending,disabled:!t.trim(),children:"Preview 5 renders"})}),S.length>0&&e.jsx(P,{withBorder:!0,children:e.jsxs(b,{gap:"xs",children:[e.jsx(g,{size:"sm",fw:600,children:"Previews:"}),S.map((s,F)=>e.jsx(h,{block:!0,style:{whiteSpace:"pre-wrap",fontSize:12},children:s},`${F}-${(s||"").slice(0,32)}`))]})}),e.jsxs(l,{justify:"flex-end",children:[e.jsx(c,{variant:"subtle",onClick:x,children:"Cancel"}),e.jsx(c,{onClick:()=>T.mutate(),loading:T.isPending,disabled:!m.trim()||!t.trim(),children:i?"Create":"Save"})]})]})})}export{ue 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.