1import{e as c,j as e,H as $,L as A,t as h}from"./app-D5Bf_dbH.js";import{S as D}from"./SuperAdminLayout-Df3A_GmM.js";import{B}from"./Breadcrumbs-DxtGVYP8.js";import{C as H,a as O,b as R,d as F}from"./card-CUwjT2hB.js";import{T as P,a as G,b as g,c as i,d as M,e as n}from"./table-Dn41ev5Z.js";import{B as p}from"./button-BooRjUAf.js";import{I as U}from"./input-DqZbbFgj.js";import{S as _}from"./spinner-CoXWKYJB.js";import{h as q,l as z}from"./super-admin-api-Bx81v1-Y.js";import"./dropdown-menu-DXUwCH2H.js";import"./react-icons.esm-CCm293eC.js";import"./index-D4lci4mZ.js";import"./index-eCYNzz1C.js";import"./index-Cn72dBP_.js";import"./index-DI8WOxmI.js";import"./index-rimmKLID.js";import"./avatar-CQYHhkys.js";import"./useGlobalShortcuts-C3mPQ3zf.js";import"./react-BPWwdghM.js";import"./chevron-right-Ba0gC1l7.js";import"./createLucideIcon-CyKN5i_O.js";import"./sheet-lU-qfqG8.js";import"./index-B02_DhYT.js";import"./scroll-area-CnV8vZPq.js";import"./index-D17hSi50.js";import"./rotate-ccw-hNqG30TC.js";import"./eye-jUg7xQoe.js";import"./user-CODNnX9U.js";import"./CSLOGO_lghtbg-12-DL8MB5gQ.js";import"./dialog-BgEHdzUT.js";import"./popover-CBJwT1Kl.js";import"./badge-BdtyRZeW.js";import"./shopping-cart-BYHhTvfT.js";import"./users-jvAb0Hsa.js";import"./lock-_lQojS3k.js";import"./search-F-2nffFh.js";import"./settings-x0uW8CTG.js";import"./log-out-Cqz61TM3.js";import"./sonner-CJXwkPTZ.js";import"./file-text-Bn6-_gGR.js";import"./loader-circle-CNDCpqRX.js";const N=a=>[a.inserted_on??"",`${a.client_type??""}/${a.client_name??""}`,`${a.device_type??""}/${a.client_os??""}`,`Reminder ${a.email_index??""}`].join(" | "),Ae=()=>{const[a,y]=c.useState(""),[x,u]=c.useState(!1),[C,k]=c.useState(!1),[b,v]=c.useState(""),[j,S]=c.useState([]),[f,T]=c.useState(null),[w,o]=c.useState({}),I=async r=>{r.preventDefault();const t=a.trim();if(!t){h.error("Funny enough... the cart id must be a number. Please try again.");return}u(!0),o({});try{const s=await q(t);S(s.events),T(s.account),v(t),k(!0)}catch(s){h.error(s instanceof Error?s.message:"Failed to load tracking activity")}finally{u(!1)}},E=async r=>{if(r.send_archive_id===null)return;const t=r.send_archive_id;o(s=>({...s,[t]:{loading:!0,data:null}}));try{const s=await z(r.site_id,t,r.cart_id);o(l=>({...l,[t]:{loading:!1,data:s}}))}catch(s){o(l=>{const d={...l};return delete d[t],d}),h.error(s instanceof Error?s.message:"Failed to load open/click data")}},L=r=>{if(r.is_send&&r.send_archive_id!==null){const t=w[r.send_archive_id];if(t?.loading)return e.jsxs("div",{className:"flex items-center text-sm text-muted-foreground",children:[e.jsx(_,{className:"mr-2"})," Loading..."]});if(t?.data){const{opens:s,clicks:l}=t.data;return s.length===0&&l.length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No Opens or Clicks..."}):e.jsxs("div",{className:"space-y-2 text-xs",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"Opens:"}),s.length===0?e.jsx("div",{className:"text-muted-foreground pl-2",children:"None"}):s.map((d,m)=>e.jsx("div",{className:"pl-2",children:N(d)},`o-${m}`))]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"Clicks:"}),l.length===0?e.jsx("div",{className:"text-muted-foreground pl-2",children:"None"}):l.map((d,m)=>e.jsx("div",{className:"pl-2",children:N(d)},`c-${m}`))]})]})}return e.jsx(p,{variant:"link",className:"h-auto p-0",onClick:()=>E(r),children:"Load Open/Click Data"})}return r.browser_details?e.jsxs("span",{className:"text-sm",children:["Browser: ",r.browser_details]}):null};return e.jsxs(D,{header:e.jsx(B,{items:[{name:"Dashboard",link:route("sa.dashboard"),
1current:!1},{name:"Tracking Activity",link:route("sa.tracking-activity.index"),current:!0}]}),children:[e.jsx($,{title:"Tracking Activity"}),e.jsxs(H,{children:[e.jsx(O,{children:e.jsx(R,{children:"Tracking Activity"})}),e.jsxs(F,{children:[e.jsxs("div",{className:"flex items-end justify-between gap-4 flex-wrap",children:[e.jsxs("form",{onSubmit:I,className:"flex items-end gap-2",children:[e.jsx(U,{placeholder:"Cart ID",maxLength:10,inputMode:"numeric",value:a,onChange:r=>y(r.target.value),className:"w-64"}),e.jsx(p,{type:"submit",disabled:x,children:x?e.jsxs(e.Fragment,{children:[e.jsx(_,{className:"mr-2"})," Searching..."]}):"Go"})]}),f&&e.jsx(p,{asChild:!0,variant:"outline",children:e.jsx(A,{href:route("sa.customers.profile",{id:f.id}),children:"Account Profile"})})]}),C&&e.jsx("div",{className:"mt-6",children:j.length===0?e.jsxs("p",{className:"text-center text-muted-foreground py-8",children:["No results for cart id ",b,"..."]}):e.jsxs(P,{children:[e.jsx(G,{children:e.jsxs(g,{children:[e.jsx(i,{children:"Cart ID"}),e.jsx(i,{children:"Email Address"}),e.jsx(i,{children:"Transaction Date"}),e.jsx(i,{children:"Event Type"}),e.jsx(i,{children:"Event Details"}),e.jsx(i,{children:"Referring URL"}),e.jsx(i,{children:"Cart Total"}),e.jsx(i,{children:"Cart Items"})]})}),e.jsx(M,{children:j.map((r,t)=>e.jsxs(g,{className:"align-top",children:[e.jsx(n,{children:r.cart_id}),e.jsx(n,{children:r.email_address}),e.jsx(n,{className:"whitespace-nowrap",children:r.transaction_date}),e.jsx(n,{children:r.event_type}),e.jsx(n,{children:L(r)}),e.jsx(n,{className:"max-w-xs break-all",children:r.referring_url}),e.jsx(n,{children:r.cart_total}),e.jsx(n,{children:r.cart_items})]},`${r.send_archive_id??"na"}-${t}`))})]})})]})]})]})};export{Ae 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.