PageSourceSearch

https://smartmail.ai/assets/EmailsPage-BfeL-b49.js

js smartmail.ai collected 2026-10-05 14:17:06 UTC 24,855 bytes, 1 lines download raw bytes

1import{q as L,r as i,A as Ve,e as Pe,u as Le,h as se,j as e,S as de,B as m,M as ve,f as Xe,b as Ze,g as et,al as tt,C as st,am as nt,T as W}from"./index-BrT3F50e.js";import{u as it}from"./useMutation-Df2IkzNR.js";import{t as je}from"./index-Cw5ISF4o.js";import{F as T,g as we,h as Te,i as De,f as Ee,c as _e}from"./index-aiUU9uK4.js";import{E as at,a as ot,P as lt}from"./EmptyState-BsaFrTWq.js";import{d as rt,n as Y,f as Se}from"./dayjs-CSchl2My.js";import{T as ke}from"./TemplatePreviewDrawer-Dr10TA_N.js";import{D as Ae,a as ze,b as Ie,A as dt,S as ct,w as mt,s as pt,R as ut,t as Me}from"./SendingWindowFields-lscLyaGL.js";import{b as Fe}from"./broadcast-DTyl9Ml3.js";import{l as ht}from"./list-8nSQBgxW.js";import{c as xt}from"./contacts-C1xHMXIW.js";import{l as gt}from"./segment-Bwak2QKo.js";import{D as yt}from"./SettingsIcons-BTuZkbEP.js";import{T as We}from"./index-JIFlWX-e.js";import{I as te}from"./index-BI2D8MSW.js";import{S as ft,D as jt}from"./index-H103cwmy.js";import{S as ne}from"./index-DF5CAhcZ.js";import{R as St}from"./SendOutlined-GcVD1f-c.js";import{T as Oe}from"./index-DIQCRyy8.js";import{P as bt}from"./index-DG69r-Xk.js";import{R as vt}from"./LeftOutlined-C9qxU1fR.js";import{R as Ft}from"./PlusOutlined-B06sW5qS.js";import{F as Ne}from"./Table-6SzYbSzL.js";import{s as Ye}from"./index-DtDFBFnu.js";import{S as Ct}from"./index-DDdNZ6K1.js";import"./timezoneNormalizer-l1yj-VtS.js";import"./index-KB2153Cz.js";import"./index-DRrMmQ2c.js";import"./index-BI849doy.js";import"./styleChecker-CI4V7a_h.js";import"./TextArea-BpydDq59.js";import"./getAllowClear-C4A34otO.js";import"./Input-DOcZa3u3.js";import"./Overflow-BkMYm1DN.js";import"./EllipsisOutlined-Cu-qV7Vg.js";import"./Dropdown-DXdTgnhA.js";import"./index-BDXfpOYW.js";import"./useForm-BVKnLQxW.js";import"./index-Cl3KiXUs.js";import"./Sider-DNV35gRJ.js";import"./useBreakpoint-FD8ghq8d.js";import"./Pagination-DBPbQz54.js";import"./gapSize-U1swVQyS.js";const wt={list:async s=>{const a=new URLSearchParams;return a.append("workspace_id",s.workspace_id),s.search&&a.append("search",s.search),s.limit&&a.append("limit",s.limit.toString()),s.offset&&a.append("offset",s.offset.toString()),L.get(`/api/transactional.list?${a.toString()}`)},get:async s=>{const a=new URLSearchParams;return a.append("workspace_id",s.workspace_id),a.append("id",s.id),L.get(`/api/transactional.get?${a.toString()}`)},create:async s=>L.post("/api/transactional.create",s),update:async s=>L.post("/api/transactional.update",s),delete:async s=>L.post("/api/transactional.delete",s),send:async s=>L.post("/api/transactional.send",s),testTemplate:(s,a,h,o,d,l)=>{const g={workspace_id:s,template_id:a,integration_id:h,sender_id:o,recipient_email:d,email_options:l};return L.post("/api/transactional.testTemplate",g)}},{Text:S}=We;function Tt({isOpen:s,onClose:a,template:h,workspace:o,loading:d=!1}){const[l,g]=i.useState("send"),[_,v]=i.useState(""),[y,c]=i.useState(""),[b,x]=i.useState(""),[F,D]=i.useState(!1),[B,C]=i.useState(""),[k,f]=i.useState([]),[j,O]=i.useState([]),[A,K]=i.useState(""),[z,H]=i.useState(!1),[p,$]=i.useState(null),[u,q]=i.useState(!1),[R,G]=i.useState(null),[P,Q]=i.useState(Ae),[J,U]=i.useState(ze),[I,V]=i.useState(Ie),{message:E}=Ve.useApp(),ie=Pe(),{user:ce,refreshUser:me}=Le(),ae=Math.max(0,ce?.credits_left??0),[pe,X]=i.useState(null),M=i.useMemo(()=>o?.integrations?.filter(n=>n.type==="email"&&n.email_provider?.kind)||[],[o?.integrations]),{data:oe,isLoading:t}=se({queryKey:["contacts-count",o?.id],queryFn:()=>xt.getTotalContacts({workspace_id:o.id}),enabled:s&&!!o?.id}),r=oe?.total_contacts,{data:le,isLoading:re}=se({queryKey:["segments",o?.id],queryFn:()=>gt({workspace_id:o.id,with_count:!0}),enabled:s&&!!o?.id}),ue=le?.segments||[],{data:$e}=se({queryKey:["lists",o?.id],queryFn:()=>ht.list({workspace_id:o.id}),enabled:s&&!!o?.id}),he=$e?.lists?.[0]?.id||"",Z=i.useMemo(()=>p===null?0:p.length===0?r??0:ue.filter(n=>p.includes(n.id)).reduce((n,w)=>n+(w.users_count??0),0),[p,ue,r]);i.useEffect(()=>{if(p===null||!o?.id){X(null);return}Fe.estimateInDays({workspace_id:o.id,recipient_count:Z}).then(n=>{X(n.days)}).catch(n=>{console.error("Failed to estimate broadcast:",n),X(null)})},[p,Z,o?.id]),i.useEffect(()=>{if(s&&o&&M.length>0&&!y){const n=h?.category==="marketing"?o.settings?.marketing_email_provider_id:o.settings?.transactional_email_provider_id,w=n&&M.some(fe=>fe.id===n)?n:M[0]?.id||"";c(w);const Je=M.find(fe=>fe.id===w);x(Je?.email_provider?.senders[0]?.id||"")}},[s,h,o,M,y]),i.useEffect(()=>{s&&(v(""),C(""),f([]),O([]),K(""),H(!1),$(null),g("send"),q(!1),G(null),Q(Ae),U(ze),V(Ie))},[s]);const qe=async()=>
1{if(!(!h||!o||!y||!he||p===null)){if(Z>ae){E.error("Not enough credits to send this email");return}D(!0);try{const n=p.length===0?{list:he,exclude_unsubscribed:!0}:{list:he,segments:p,exclude_unsubscribed:!0},w=!u;await Fe.create({workspace_id:o.id,name:`Send: ${h.name}`,audience:n,send_now:w,schedule:{is_scheduled:u,scheduled_date:u&&R||void 0,scheduled_time:u?P:void 0,use_recipient_timezone:!1,send_days:I,start_hour:Me(P),end_hour:Me(J)},test_settings:{enabled:!1,sample_percentage:0,auto_send_winner:!1,variations:[{variation_name:"default",template_id:h.id}]}}),await me(),E.success(u?"Email scheduled successfully":"Email sent successfully"),a()}catch(n){const w=n?.response?.status===400&&n?.response?.data?.message?n.response.data.message:n?.message||"Something went wrong";E.error(`Error: ${w}`)}finally{D(!1)}}},Ue=async()=>{if(!(!h||!o||!y)){D(!0);try{const n=await wt.testTemplate(o.id,h.id,y,b,_,{from_name:B||void 0,cc:k,bcc:j,reply_to:A});n.success?(E.success("Test email sent successfully"),a()):E.error(`Failed to send test email: ${n.error||"Unknown error"}`)}catch(n){const w=n?.response?.status===400&&n?.response?.data?.message?n.response.data.message:n?.message||"Something went wrong";E.error(`Error: ${w}`)}finally{D(!1)}}},xe=M.find(n=>n.id===y)?.email_provider?.senders.find(n=>n.id===b),Ce=xe?`${xe.name} <${xe.email}>`:"No sender configured",N={fontWeight:500,fontSize:14,color:"#1C1D1F",display:"block",marginBottom:8},ge=ie?16:14,ee={height:50,borderRadius:10,background:"#F4F4F5",border:"1px solid #E7E7E7",padding:"0 20px",fontSize:ge},ye={fontSize:14,color:"#1C1D1F",opacity:.3,lineHeight:1.3},Ke=e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:20},children:[e.jsx(S,{style:ye,children:"Re-sent the email with it's surrent contents and subject line."}),e.jsxs("div",{children:[e.jsx(S,{style:N,children:"Sender"}),e.jsx(te,{value:Ce,disabled:!0,style:ee})]}),e.jsxs("div",{children:[e.jsx(S,{style:N,children:"Audience"}),t||re?e.jsx("div",{style:{padding:12,textAlign:"center"},children:e.jsx(de,{size:"small"})}):e.jsx(dt,{segments:ue,selectedSegmentIds:p,onChange:$,totalContacts:r,audienceCount:Z})]}),e.jsx(ct,{sendingTimeFrom:P,onSendingTimeFromChange:Q,sendingTimeTo:J,onSendingTimeToChange:U,sendDays:I,onSendDaysChange:V}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 0",borderTop:"1px solid #F0F0F0",borderBottom:u?"none":"1px solid #F0F0F0"},children:[e.jsx(S,{style:{fontSize:14,fontWeight:500,color:"#1C1D1F"},children:"Schedule for later delivery"}),e.jsx(ft,{checked:u,onChange:q})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingBottom:"20px",borderBottom:u?"none":"1px solid #F0F0F0"},children:e.jsxs(S,{style:{fontSize:14,fontWeight:500,color:"#1C1D1F"},children:["Estimated period: ",e.jsxs("span",{style:{fontWeight:600,color:"#111827"},children:["~",pe," days"]})]})}),e.jsx("div",{style:{fontSize:12,color:"#00000073",marginTop:-12,marginBottom:8},children:"Credits are charged only for emails actually sent. Unsubscribed and duplicated contacts are skipped, so the number of emails sent may be lower than your segment size."}),u&&e.jsxs("div",{style:{paddingBottom:16,borderBottom:"1px solid #F0F0F0"},children:[e.jsxs(S,{style:{fontWeight:500,display:"block",marginBottom:6},children:["Select date",e.jsx("span",{style:{color:"#FB2F4A"},children:"*"})]}),e.jsx(jt,{format:"YYYY-MM-DD",value:R?rt(R):null,onChange:n=>G(n?n.format("YYYY-MM-DD"):null),...mt(o?.settings.timezone),style:{width:"100%",borderRadius:16,height:49,background:"#F4F4F5",borderColor:"#E7E7E7"},placeholder:"Select Date"})]})]}),He=e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:20},children:[e.jsx(S,{style:ye,children:"Sent a test email using this template to verify how it will look."}),e.jsxs("div",{children:[e.jsx(S,{style:N,children:"Sender"}),e.jsx(te,{value:Ce,disabled:!0,style:ee})]}),e.jsxs("div",{children:[e.jsxs(S,{style:N,children:["Recipient Email",e.jsx("span",{style:{color:"#FB2F4A"},children:"*"})]}
1),e.jsx(te,{placeholder:"[email protected]",value:_,onChange:n=>v(n.target.value),type:"email",style:ee})]}),!z&&e.jsx("div",{onClick:()=>H(!0),style:{fontSize:13,fontWeight:500,color:"#2F6DFB",cursor:"pointer",userSelect:"none"},children:"+ add form name, CC, BCC, reply to, etc."}),z&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(S,{style:N,children:"From Narrative (override)"}),e.jsx(te,{placeholder:"Custom Sender Name (optional)",value:B,onChange:n=>C(n.target.value),allowClear:!0,style:ee}),e.jsx(S,{style:{...ye,fontSize:12,marginTop:4,display:"block"},children:"Override the default sender name for this test email"})]}),e.jsxs("div",{children:[e.jsx(S,{style:N,children:"CC Recipients"}),e.jsx(ne,{mode:"tags",placeholder:"Enter CC email addresses",value:k,onChange:f,tokenSeparators:[","," "],allowClear:!0,style:{width:"100%",minHeight:50,borderRadius:10,fontSize:ge},variant:"filled"})]}),e.jsxs("div",{children:[e.jsx(S,{style:N,children:"BCC Recipients"}),e.jsx(ne,{mode:"tags",placeholder:"Enter BCC email addresses",value:j,onChange:O,tokenSeparators:[","," "],allowClear:!0,style:{width:"100%",minHeight:50,borderRadius:10,fontSize:ge},variant:"filled"})]}),e.jsxs("div",{children:[e.jsx(S,{style:N,children:"Reply-To"}),e.jsx(te,{placeholder:"Enter reply-to email address",value:A,onChange:n=>K(n.target.value),allowClear:!0,style:ee})]})]})]}),Ge=p===null||!y||F||(r??0)===0||!pt(P,J,I)||u&&!R,Qe=l==="send"?[e.jsx(m,{onClick:a,className:"flex-1",size:"large",children:"Cancel"},"cancel"),e.jsxs(m,{type:"primary",onClick:qe,disabled:Ge,loading:F,size:"large",className:"flex-1",style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8},children:[e.jsx(St,{}),u?e.jsx("span",{children:"Schedule"}):e.jsx("span",{children:"Send Now"}),e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,marginLeft:8,opacity:.8},children:[e.jsx(yt,{size:14}),e.jsxs("span",{children:[Z," / ",ae.toLocaleString()]})]})]},"send")]:[e.jsx(m,{onClick:a,className:"flex-1",size:"large",children:"Cancel"},"cancel"),e.jsxs(m,{type:"primary",onClick:Ue,disabled:!_||!y||d||F,loading:d||F,size:"large",className:"flex-1",children:["Send Test Email ",e.jsx(ut,{})]},"test")];return e.jsx(ve,{title:null,open:s,onCancel:a,footer:Qe,width:520,closable:!0,styles:{footer:{display:"flex",gap:12}},children:e.jsx(Oe,{activeKey:l,onChange:g,items:[{key:"send",label:e.jsx("span",{style:{fontSize:15,fontWeight:600},children:"Send Email"}),children:Ke},{key:"test",label:e.jsx("span",{style:{fontSize:15,fontWeight:600},children:"Test Send"}),children:He}]})})}const Be={sent:{bg:"#2F6DFB",border:"#2F6DFB",text:"#FFFFFF"},sending:{bg:"#76B82A",border:"#76B82A",text:"#FFFFFF"},scheduled:{bg:"#FFBA00",border:"#FFBA00",text:"#FFFFFF"},draft:{bg:"#D9D909",border:"#D9D909",text:"#666666"}},Dt=["SUNDAY","MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY"];function Et(s){return Be[s]||Be.scheduled}function _t(s,a){return s==="sending"?a&&a>0?`Sending: ~${a}d left`:"Sending":s.charAt(0).toUpperCase()+s.slice(1)}function Re({event:s}){const a=Et(s.status);return e.jsxs("div",{style:{borderRadius:5,border:`1px solid ${a.border}`,backgroundColor:"#FAFAFA",overflow:"hidden",width:"100%"},children:[e.jsx("div",{style:{backgroundColor:a.bg,color:a.text,padding:"3px 6px",fontSize:11,fontWeight:500,lineHeight:"18px"},children:_t(s.status,s.leftDays)}),s.name&&e.jsx("div",{style:{padding:"3px 6px",fontSize:12,color:"#1C1D1F",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.name})]})}function kt(s){const a=s.startOf("month"),h=s.endOf("month"),o=a.day(),d=a.subtract(o,"day"),l=[];let g=d;for(let v=0;v<6;v++){const y=[];for(let c=0;c<7;c++)y.push(g),g=g.add(1,"day");l.push(y)}return l[l.length-1][0].isAfter(h)&&l.pop(),l}function At({workspaceId:s,currentDate:a,timezone:h}){const{data:o,isLoading:d}=se({queryKey:["broadcasts-schedules",s],queryFn:()=>Fe.schedules({workspace_id:s,limit:1e3})}),l=i.useMemo(()=>o?.data?o.data.map(c=>({id:c.id,name:c.name,status:c.status??"unknown",leftDays:c.left_days,date:c.schedule.scheduled_date||""})):[],[o]),g=i.useMemo(()=>{const c=new Map;for(const b of l){if(!b.date)continue;const x=b.date;c.has(x)||c.set(x,[]),c.get(x).push(b)}return c},[l]),_=i.useMemo(()=>kt(a),[a]),v=Y(h).format("YYYY-MM-DD"),y=a.month();
1return d?e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"60px 0"},children:e.jsx(de,{size:"small"})}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,overflow:"auto",padding:"0 20px 20px",background:"#FAFAFA"},children:[e.jsx("div",{style:{display:"flex",borderBottom:"1px solid #E4E4E4"},children:Dt.map(c=>e.jsx("div",{style:{flex:1,textAlign:"center",padding:"10px 0",fontSize:12,fontWeight:600,color:"rgba(28, 29, 31, 0.4)",textTransform:"uppercase",letterSpacing:"0.5px"},children:c},c))}),e.jsx("div",{style:{display:"flex",flexDirection:"column",flex:1},children:_.map((c,b)=>e.jsx("div",{style:{display:"flex",flex:1,minHeight:100},children:c.map(x=>{const F=x.format("YYYY-MM-DD"),D=F===v,B=x.month()===y,C=g.get(F)||[],k=C.length>2,f=k?C.slice(0,2):C;return e.jsxs("div",{style:{flex:1,border:"1px solid #E4E4E4",borderTop:"none",borderLeft:"none",padding:10,display:"flex",flexDirection:"column",gap:6,backgroundColor:D?"#EBF0FF":void 0,...c.indexOf(x)===0?{borderLeft:"1px solid #E4E4E4"}:{}},children:[e.jsxs("div",{style:{display:"flex",justifyContent:k?"space-between":"flex-end",alignItems:"center"},children:[k&&e.jsx(bt,{trigger:"click",title:x.format("MMMM D, YYYY"),content:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,maxHeight:300,overflowY:"auto",width:200},children:C.map(j=>e.jsx(Re,{event:j},j.id))}),children:e.jsxs("span",{style:{fontSize:12,color:"#2F6DFB",cursor:"pointer",fontWeight:500},children:[C.length,"+ Emails"]})}),e.jsx("span",{style:{fontSize:13,fontWeight:500,color:D?"#2F6DFB":B?"#1C1D1F":"#C0C0C0"},children:x.date()})]}),f.map(j=>e.jsx(Re,{event:j},j.id))]},F)})},b))})]})}const{Text:be}=We,zt={components:{Tabs:{itemColor:"rgba(28, 29, 31, 0.5)",itemHoverColor:"rgba(28, 29, 31, 0.7)",itemSelectedColor:"#1C1D1F",inkBarColor:"#2F6DFB",titleFontSize:16,titleFontSizeLG:16,colorBgContainer:"#FAFAFA",controlHeight:60,cardHeight:60,horizontalMargin:"0 0 0 0"}}},It=["January","February","March","April","May","June","July","August","September","October","November","December"];function Cs(){const{workspaceId:s}=Xe({from:"/workspace/$workspaceId/templates"}),a=Ze(),h=et(),{workspaces:o}=Le(),{permissions:d}=tt(s),l=i.useMemo(()=>o.find(t=>t.id===s)??null,[o,s]),[g,_]=i.useState("list"),[v,y]=i.useState("newest"),[c,b]=i.useState(1),[x,F]=i.useState(10),[D,B]=i.useState(!1),[C,k]=i.useState(null),f=Pe(),j=l?.settings.timezone,[O,A]=i.useState(()=>Y(j)),[K,z]=i.useState(()=>Y(j).month()),[H,p]=i.useState(()=>Y(j).year());i.useEffect(()=>{if(!j)return;const t=Y(j);A(t),z(t.month()),p(t.year())},[j]);const{data:$,isLoading:u}=se({queryKey:["templates",s],queryFn:()=>je.list({workspace_id:s,channel:"email"})}),q=it({mutationFn:je.delete,onSuccess:()=>{Ye.success("Template deleted successfully"),h.invalidateQueries({queryKey:["templates",s]})},onError:t=>{const r=t?.response?.data?.error||t.message;Ye.error(`Failed to delete template: ${r}`)}}),R=t=>{q.mutate({workspace_id:s,id:t})},G=async t=>{try{await je.clone({workspace_id:s,id:t}),h.invalidateQueries({queryKey:["templates",s]})}catch(r){console.error("Failed to clone template:",r)}},P=t=>{k(t),B(!0)},Q=t=>{a({to:"/workspace/$workspaceId/campaign/$templateId/edit",params:{workspaceId:s,templateId:t}})},J=()=>{a({to:"/workspace/$workspaceId/create",params:{workspaceId:s}})},U=$?.templates,I=i.useMemo(()=>U?[...U].sort((t,r)=>{const le=new Date(t.created_at).getTime(),re=new Date(r.created_at).getTime();return v==="newest"?re-le:le-re}):[],[U,v]),V=i.useMemo(()=>{const t=(c-1)*x;return I.slice(t,t+x)},[I,c,x]),E=!u&&I.length>0,ie=!u&&(!$?.templates||$.templates.length===0);if(!l)return e.jsx("div",{style:{textAlign:"center",padding:"40px 0"},children:e.jsx(de,{size:"small"})});const ce=()=>{const t=Y(l.settings.timezone);A(t),z(t.month()),p(t.year())},me=()=>{const t=O.subtract(1,"month");A(t),z(t.month()),p(t.year())},ae=()=>{const t=O.add(1,"month");A(t),z(t.month()),p(t.year())},pe=()=>{A(Y(l.settings.timezone).month(K).year(H).startOf("month"))},X=Y(l.settings.timezone).year(),M=Array.from({length:11}
1,(t,r)=>X-5+r).map(t=>({label:String(t),value:t})),oe=[{title:"Name",dataIndex:"name",key:"name",render:t=>e.jsx(be,{strong:!0,children:t})},{title:"Subject line",dataIndex:["email","subject"],key:"subject",render:(t,r)=>e.jsxs("div",{children:[e.jsx(be,{strong:!0,children:t}),r.email?.subject_preview&&e.jsx("div",{children:e.jsx(be,{type:"secondary",className:"text-xs",children:r.email.subject_preview})})]})},{title:"Created",dataIndex:"created_at",key:"created_at",render:t=>e.jsx(W,{title:Se(t,l?.settings.timezone,"llll")+" in "+l?.settings.timezone,children:e.jsx("span",{children:Se(t,l?.settings.timezone,"ll")})})},{title:"",key:"actions",align:"right",width:180,render:(t,r)=>e.jsxs(Ct,{children:[l&&e.jsx(W,{title:d?.templates?.write?"Edit Email":"You don't have write permission for emails",children:e.jsx(m,{type:"text",size:"small",icon:e.jsx(T,{icon:we,style:{opacity:.7}}),disabled:!d?.templates?.write,onClick:()=>Q(r.id)})}),l&&e.jsx(W,{title:d?.templates?.write?"Clone Email":"You don't have write permission for emails",children:e.jsx("div",{children:e.jsx(m,{type:"text",icon:e.jsx(T,{icon:Te,style:{opacity:.7}}),disabled:!d?.templates?.write||!!r.integration_id,onClick:()=>{G(r.id)}})})}),e.jsx(W,{title:r.integration_id?"This email is managed by an integration and cannot be deleted":d?.templates?.write?"Delete Email":"You don't have write permission for emails",children:e.jsx(m,{type:"text",icon:e.jsx(T,{icon:De,style:{opacity:.7}}),loading:q.isPending,disabled:!d?.templates?.write||!!r.integration_id,onClick:()=>{ve.confirm({title:"Delete email?",content:e.jsxs("div",{children:[e.jsx("p",{children:"Are you sure you want to delete this email?"}),e.jsx("p",{className:"mt-2 text-gray-600",children:"Note: The email will be hidden from your workspace but preserved to maintain the ability to preview previously sent broadcasts and messages that used this email."})]}),okText:"Yes, Delete",okType:"danger",cancelText:"Cancel",onOk:()=>R(r.id)})}})}),e.jsx(W,{title:d?.templates?.read&&d?.contacts?.write?"Send Email":"You need read template and write contact permissions to send test emails",children:e.jsx(m,{type:"text",icon:e.jsx(T,{icon:Ee,style:{opacity:.7}}),onClick:()=>P(r),disabled:!(d?.templates?.read&&d?.contacts?.write)})}),e.jsx(W,{title:"Preview Email",children:e.jsx(e.Fragment,{children:e.jsx(ke,{record:r,workspace:l,children:e.jsx(m,{type:"text",icon:e.jsx(T,{icon:_e,style:{opacity:.7}})})})})})]})}];return e.jsxs("div",{className:"flex flex-col",style:{height:f?"calc(100vh - 56px)":"100vh"},children:[e.jsx("div",{className:"shrink-0",style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:f?"0 16px":"0 20px",height:f?50:60,backgroundColor:"#FAFAFA",borderBottom:"1px solid #EAEAEC"},children:e.jsx("h1",{style:{fontSize:f?22:24,fontWeight:600,color:"#1C1D1F",marginBottom:0},children:"My Emails"})}),e.jsxs("div",{className:"shrink-0",style:{padding:f?"0 16px":"0 20px",background:"#FAFAFA",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(st,{theme:zt,children:e.jsx(Oe,{activeKey:g,items:[{key:"list",label:e.jsx("span",{style:{fontWeight:700},children:"Emails List"})},{key:"calendar",label:e.jsx("span",{style:{fontWeight:700},children:"Calendar View"})}],onChange:t=>_(t),style:{marginBottom:0}})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[g==="list"&&e.jsx(ne,{value:v,onChange:t=>{y(t),b(1)},style:{width:f?150:170},size:f?"small":"middle",options:[{label:"Newest on top",value:"newest"},{label:"Oldest on top",value:"oldest"}]}),g==="calendar"&&!f&&e.jsxs(e.Fragment,{children:[e.jsx(m,{onClick:ce,style:{borderRadius:20},children:"Today"}),e.jsxs(m.Group,{children:[e.jsx(m,{icon:e.jsx(vt,{}),onClick:me}),e.jsx(m,{icon:e.jsx(nt,{}),onClick:ae})]}),e.jsx(ne,{value:K,onChange:z,style:{width:130},options:It.map((t,r)=>({label:t,value:r}))}),e.jsx(ne,{value:H,onChange:p,style:{width:90},options:M}),e.jsx(m,{onClick:pe,children:"Go"})]})]})]}),g==="list"?e.jsxs(e.Fragment,{children:[ie?e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center",children:e.jsx(at,{icon:e.jsx(ot,{}),title:"No Emails Created Yet",action:e.jsx(W,{title:d?.templates?.write?void 0:"You don't have write permission for emails",children:e.jsx("div",{children:e.jsxs(m,{type:"primary",size:"large",disabled:!d?.templates?.write,style:{borderRadius:"10px"},onClick:J,children:[e.jsx(Ft,{})," Create Email"]})})})})}):f?e.jsx("div",{className:"flex-1 overflow-auto",style:{padding:"12px 16px"},children:u?e.jsx("div",{style:{textAlign:"center",padding:"40px 0"},children:e.jsx(de,{size:"small"})}):E?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:V.map(t=>e.jsxs("div",{style:{backgroundColor:"#FAFAFA",borderRadius:12,padding:"12px 14px",border:"1px solid #F0F0F0"},children:[e.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:e.jsx("div",{style:{fontSize:15,fontWeight:600,color:"#1C1D1F"},children:t.name})}),t.email?.subject&&e.jsx("div",{style:{fontSize:13,color:"rgba(28,29,31,0.6)",marginTop:2},children:t.email.subject}),t.email?.subject_preview&&e.jsx("div",{style:{fontSize:12,color:"rgba(28,29,31,0.4)",marginTop:1},children:t.email.subject_preview}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:10,borderTop:"1px solid #F0F0F0",paddingTop:8},children:[e.jsx("div",{style:{fontSize:12,color:"rgba(28,29,31,0.4)"},children:Se(t.created_at,l?.settings.timezone,"ll")}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx(m,{type:"text",size:"small",icon:e.jsx(T,{icon:we,style:{opacity:.7}}),disabled:!d?.templates?.write,onClick:()=>Q(t.id)}),e.jsx(m,{type:"text",size:"small",icon:e.jsx(T,{icon:Te,style:{opacity:.7}}),disabled:!d?.templates?.write,onClick:()=>G(t.id)}),e.jsx(m,{type:"text",size:"small",icon:e.jsx(T,{icon:De,style:{opacity:.7}}),loading:q.isPending,disabled:!d?.templates?.write||!!t.integration_id,onClick:()=>{ve.confirm({title:"Delete template?",content:e.jsxs("div",{children:[e.jsx("p",{children:"Are you sure you want to delete this email?"}),e.jsx("p",{className:"mt-2 text-gray-600",children:"Note: The email will be hidden from your workspace but preserved to maintain the ability to preview previously sent broadcasts and messages that used this email."})]}),okText:"Yes, Delete",okType:"danger",cancelText:"Cancel",onOk:()=>R(t.id)})}}),e.jsx(m,{type:"text",size:"small",icon:e.jsx(T,{icon:Ee,style:{opacity:.7}}),onClick:()=>P(t),disabled:!(d?.templates?.read&&d?.contacts?.write)}),e.jsx(ke,{record:t,workspace:l,children:e.jsx(m,{type:"text",size:"small",icon:e.jsx(T,{icon:_e,style:{opacity:.7}})})})]})]})]},t.id))}):e.jsx("div",{style:{textAlign:"center",padding:"40px 0",color:"rgba(28, 29, 31, 0.4)"},children:"No emails found"})}):e.jsx("div",{className:"flex-1 overflow-auto px-5 py-6",children:u?e.jsx(Ne,{columns:oe,dataSource:[],loading:!0,rowKey:"id"}
1):E?e.jsx("div",{style:{backgroundColor:"#FAFAFA",borderRadius:"20px",padding:"10px",overflow:"hidden"},children:e.jsx(Ne,{className:"table-no-cell-border",columns:oe,dataSource:V,rowKey:"id",pagination:!1,rowClassName:(t,r)=>r%2===1?"zebra-row":""})}):e.jsx("div",{style:{textAlign:"center",padding:"40px 0",color:"rgba(28, 29, 31, 0.4)"},children:"No emails found"})}),!ie&&e.jsx(lt,{totalItems:I.length,currentPage:c,pageSize:x,onPageChange:b,onPageSizeChange:t=>{F(t),b(1)},loading:u,emptyLabel:"No campaigns",isMobile:f})]}):e.jsx(At,{workspaceId:s,currentDate:O,timezone:l?.settings.timezone}),e.jsx(Tt,{isOpen:D,onClose:()=>B(!1),template:C,workspace:l})]})}export{Cs as EmailsPage};

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.