1import{z as s,j as e}from"./ui-vendor-B5O6TaIB.js";import{r as a,L as k}from"./react-vendor-Dwsg5a2_.js";import{a as d,_ as v,N as w,a0 as C,af as T,O as S}from"./index-Cbf_hYLb.js";function E(){const[x,p]=a.useState([]),[h,b]=a.useState(!0),[f,n]=a.useState(!1),[r,c]=a.useState({subject:"",recipient_email:""}),[u,m]=a.useState(!1);a.useEffect(()=>{o()},[]);const o=async()=>{try{const t=await d.get("/api/etracker");p(t.data)}catch{s.error("Failed to load trackers")}finally{b(!1)}},j=async t=>{var l,i;t.preventDefault(),m(!0);try{await d.post("/api/etracker",r),s.success("Tracker created successfully!"),c({subject:"",recipient_email:""}),n(!1),o()}catch(N){s.error(((i=(l=N.response)==null?void 0:l.data)==null?void 0:i.message)||"Failed to create tracker")}finally{m(!1)}},g=async t=>{if(window.confirm("Are you sure you want to delete this tracker?"))try{await d.delete(`/api/etracker/${t}`),s.success("Tracker deleted"),o()}catch{s.error("Failed to delete tracker")}},y=t=>{const i=`<img src="${`http://127.0.0.1:8000/track/${t}/pixel.gif`}" width="1" height="1" alt="" style="display:none;" />`;navigator.clipboard.writeText(i),s.success("Tracking Pixel HTML Copied!")};return h?e.jsx("div",{className:"p-8 text-center",children:"Loading trackers..."}):e.jsxs("div",{className:"p-6 md:p-8 max-w-6xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-neutral-dark flex items-center gap-2",children:[e.jsx(v,{className:"text-blue-600"})," E-Tracker"]}),e.jsx("p",{className:"text-neutral-muted mt-1",children:"Generate invisible tracking pixels for your emails."})]}),e.jsxs("button",{onClick:()=>n(!0),className:"flex items-center justify-center gap-2 bg-blue-600 text-white px-4 py-2 rounded-lg font-medium hover:bg-blue-700 transition-colors",children:[e.jsx(w,{})," New Tracker"]})]}),e.jsx("div",{className:"bg-white rounded-xl shadow-sm border border-neutral-border overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{className:"bg-neutral-50 text-neutral-muted text-xs uppercase tracking-wider",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-4 font-medium",children:"Subject / Campaign"}),e.jsx("th",{className:"px-6 py-4 font-medium",children:"Recipient"}),e.jsx("th",{className:"px-6 py-4 font-medium text-center",children:"Opens"}),e.jsx("th",{className:"px-6 py-4 font-medium",children:"Created"}),e.jsx("th",{className:"px-6 py-4 font-medium text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-neutral-border text-sm",children:x.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:"5",className:"px-6 py-8 text-center text-neutral-muted",children:"No trackers found. Create one to get started."})}):x.map(t=>e.jsxs("tr",{className:"hover:bg-neutral-50 transition-colors",children:[e.jsx("td",{className:"px-6 py-4 font-medium text-neutral-dark",children:t.subject}),e.jsx("td",{className:"px-6 py-4 text-neutral-muted",children:t.recipient_email||"Any"}),e.jsx("td",{className:"px-6 py-4 text-center",children:e.jsx("span",{className:"inline-flex items-center justify-center min-w-[2rem] px-2 py-1 rounded-full bg-blue-100 text-blue-700 font-bold text-xs",children:t.logs_count})}),e.jsx("td",{className:"px-6 py-4 text-neutral-muted whitespace-nowrap",children:new Date(t.created_at).toLocaleDateString()}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:()=>y(t.tracking_id),className:"p-2 text-neutral-muted hover:text-blue-600 transition-colors tooltip-trigger",title:"Copy HTML Pixel",children:e.jsx(C,{size:18})}),e.jsx(k,{to:`/dashboard/etracker/${t.id}`,className:"p-2 text-neutral-muted hover:text-blue-600 transition-colors tooltip-trigger",title:"View Analytics",children:e.jsx(T,{size:18})}),e.jsx("button",{onClick:()=>g(t.id),className:"p-2 text-neutral-muted hover:text-red-500 transition-colors tooltip-trigger",title:"Delete Tracker",children:e.jsx(S,{size:18})})]})})]},t.id))})]})})}),f&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-50",children:e.jsxs("div",{className:"bg-white rounded-2xl w-full max-w-md overflow-hidden shadow-xl animate-in fade-in zoom-in duration-200",children:[e.jsxs("div",{className:"p-6 border-b border-neutral-border",children:[e.jsx("h2",{className:"text-lg font-bold text-neutral-dark",children:"Create Tracking Pixel"}),e.jsx("p",{className:"text-sm text-neutral-muted",children:"Generate a new invisible image for your email."})]}),e.jsxs("form",{onSubmit:j,className:"p-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-neutral-dark mb-1",children:"Subject / Campaign Name *"}),e.jsx("input",{type:"text",required:!0,className:"w-full px-4 py-2 rounded-lg border border-neutral-border focus:ring-2 focus:ring-blue-600/20 focus:border-blue-600 outline-none transition-all",placeholder:"e.g. Outreach Campaign Q3",value:r.subject,onChange:t=>c({...r,subject:t.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-neutral-dark mb-1",children:"Recipient Email (Optional)"}),e.jsx("input",{type:"email",className:"w-full px-4 py-2 rounded-lg border border-neutral-border focus:ring-2 focus:ring-blue-600/20 focus:border-blue-600 outline-none transition-all",placeholder:"e.g. [email protected]",value:r.recipient_email,onChange:t=>c({...r,recipient_email:t.target.value})})]}),e.jsxs("div",{className:"pt-4 flex items-center justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:()=>n(!1),className:"px-4 py-2 text-sm font-medium text-neutral-muted hover:text-neutral-dark transition-colors",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:u,className:"px-4 py-2 bg-blue-600 text-white rounded-lg text-sm font-medium hover:bg-blue-700 transition-colors disabled:opacity-50",children:u?"Creating...":"Generate Pixel"})]})]})]})})]})}export{E 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.