PageSourceSearch

https://ctvcam.com/assets/orders-CLFO3Xtk.js

js ctvcam.com collected 2026-10-04 02:39:29 UTC 15,764 bytes, 1 lines download raw bytes

1import{a as n,j as e}from"./query-Ban24u4e.js";import{u as V,H as z,F as d,B as K,X as E,a as $}from"./index-jvhwSSW_.js";import{A as R,S as U}from"./AdminLayout-D4fzZ2x1.js";import{I as B}from"./input-DcaHre60.js";import{R as _,S as T,a as I,b as O,c as k,d as l,C as F,D as M,e as J,f as q,g as G}from"./dialog-UeF9Ts51.js";import{S as Q}from"./search-D8Je0oyf.js";import{E as W}from"./external-link-Ba34MmKG.js";import"./radix-ui-DdasXo-Q.js";import"./users-Bq-EBKxW.js";import"./chevron-right-Bm_-M2lJ.js";import"./check-Dcx7_PRd.js";const P={pending:"bg-yellow-500/10 text-yellow-400 border-yellow-500/20",paid:"bg-emerald-500/10 text-emerald-400 border-emerald-500/20",processing:"bg-blue-500/10 text-blue-400 border-blue-500/20",shipped:"bg-sky-500/10 text-sky-400 border-sky-500/20",delivered:"bg-emerald-600/10 text-emerald-300 border-emerald-600/20",cancelled:"bg-red-500/10 text-red-400 border-red-500/20",refunded:"bg-muted text-muted-foreground border-border/60"},X=[{value:"all",label:"All statuses"},{value:"pending",label:"Pending"},{value:"paid",label:"Paid"},{value:"processing",label:"Processing"},{value:"shipped",label:"Shipped"},{value:"delivered",label:"Delivered"},{value:"cancelled",label:"Cancelled"},{value:"refunded",label:"Refunded"}];function D(o){return new Date(o).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function x(o){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(Number(o))}function ce(){const[o,A]=V(),[H,h]=n.useState([]),[b,j]=n.useState(!0),[m,N]=n.useState(""),[t,u]=n.useState(null),[L,y]=n.useState(!1),[v,w]=n.useState(null),p=o.get("status")??"all",f=n.useCallback(async()=>{j(!0);try{const s=p!=="all"?`/api/orders?status=${p}`:"/api/orders",a=await fetch(s).then(r=>r.json());h(Array.isArray(a)?a:[])}catch{h([])}finally{j(!1)}},[p]);n.useEffect(()=>{f()},[f]);const C=async s=>{if(u(s),!s.items){y(!0);try{const a=await fetch(`/api/orders?id=${s.id}`).then(r=>r.json());u(a)}catch{}finally{y(!1)}}},S=(s,a)=>{w(s),fetch(`/api/orders/${s}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:a})}).then(r=>r.json()).then(r=>{h(i=>i.map(g=>g.id===s?{...g,status:r.status}:g)),(t==null?void 0:t.id)===s&&u(i=>i&&{...i,status:r.status})}).catch(()=>{}).finally(()=>w(null))},c=H.filter(s=>{if(!m)return!0;const a=m.toLowerCase();return s.customerName.toLowerCase().includes(a)||s.customerEmail.toLowerCase().includes(a)||(s.commerceOrderId??"").toLowerCase().includes(a)||(s.customerCompany??"").toLowerCase().includes(a)});return e.jsxs(R,{children:[e.jsxs(z,{children:[e.jsx("title",{children:"Orders — CTVCam Admin"}),e.jsx("meta",{name:"description",content:"Manage orders for CTVCam."}),e.jsx("link",{rel:"canonical",href:"https://ctvcam.com/admin/orders"}),e.jsx("meta",{name:"robots",content:"noindex, nofollow"}),e.jsx("meta",{property:"og:title",content:"Orders — CTVCam Admin"}),e.jsx("meta",{property:"og:description",content:"Manage orders for CTVCam."}),e.jsx("meta",{property:"og:image",content:"https://ctvcam.com/og-image.png"}),e.jsx("meta",{property:"og:url",content:"https://ctvcam.com/admin/orders"}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:image",content:"https://ctvcam.com/og-image.png"}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"WebPage",name:"Orders — CTVCam Admin",url:"https://ctvcam.com/admin/orders",noIndex:!0}).replace(/</g,"<")})]}),e.jsxs("div",{className:"max-w-6xl",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6 flex-wrap gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Orders"}),e.jsx("p",{className:"text-muted-foreground text-sm mt-0.5",children:e.jsx(d,{devId:"293220",guard:{file:"src/pages/admin/orders.tsx",tagName:"p",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:81fa182eaace3e80d9714ec2a52fb62763c20bf6c6c75bd59f0fb0353deb102d"},children:b?"Loading…":`${c.length} order${c.length!==1?"s":""}`})})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:f,className:"border-border text-muted-foreground hover:text-foreground gap-1.5",children:[e.jsx(_,{size:13}),"Refresh"]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mb-5",children:[e.jsxs("div",{className:"relative flex-1 max-w-xs",children:[e.jsx(Q,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e.jsx(B,{value:m,onChange:s=>N(s.target.value),placeholder:"Search orders…",className:"pl-8 pr-8 bg-card border-border/60 text-foreground placeholder:text-muted-foreground text-sm"}),m&&e.jsx("button",{onClick:()=>N(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground","aria-label":"Clear search",children:e.jsx(E,{size:13})})]}),e.jsxs(T,{value:p,onValueChange:s=>A(s==="all"?{}:{status:s}),children:[e.jsx(I,{className:"w-44 bg-card border-border/60 text-foreground text-sm",children:e.jsx(O,{})}),e.jsx(k,{children:X.map(s=>e.jsx(l,{value:s.value,children:s.label},s.value))})]})]}),e.jsx("div",{className:"rounded-xl border border-border/60 bg-card overflow-hidden",children:b?e.jsx("div",{className:"p-8 text-center",children:e.jsx("div",{className:"w-6 h-6 border-2 border-primary border-t-transparent roun
1ded-full animate-spin mx-auto"})}):c.length===0?e.jsxs("div",{className:"p-12 text-center",children:[e.jsx(U,{size:36,className:"text-muted-foreground/30 mx-auto mb-3"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"No orders found."})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border/60 bg-muted/30",children:[e.jsx("th",{className:"text-left px-4 py-3 text-muted-foreground font-medium text-xs uppercase tracking-wide",children:"Order ID"}),e.jsx("th",{className:"text-left px-4 py-3 text-muted-foreground font-medium text-xs uppercase tracking-wide",children:"Customer"}),e.jsx("th",{className:"text-left px-4 py-3 text-muted-foreground font-medium text-xs uppercase tracking-wide hidden sm:table-cell",children:"Total"}),e.jsx("th",{className:"text-left px-4 py-3 text-muted-foreground font-medium text-xs uppercase tracking-wide",children:"Status"}),e.jsx("th",{className:"text-left px-4 py-3 text-muted-foreground font-medium text-xs uppercase tracking-wide hidden lg:table-cell",children:"Date"}),e.jsx("th",{className:"px-4 py-3"})]})}),e.jsx("tbody",{children:c.map((s,a)=>e.jsxs("tr",{className:`border-b border-border/40 hover:bg-muted/20 transition-colors cursor-pointer ${a===c.length-1?"border-b-0":""}`,onClick:()=>C(s),children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsxs("p",{className:"text-foreground font-mono text-xs font-semibold",children:["#",s.id]}),s.commerceOrderId&&e.jsxs("p",{className:"text-muted-foreground text-xs mt-0.5 truncate max-w-[120px]",title:s.commerceOrderId,children:[s.commerceOrderId.slice(0,12),"…"]})]}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("p",{className:"text-foreground font-medium",children:s.customerName}),e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:s.customerEmail})]}),e.jsx("td",{className:"px-4 py-3 hidden sm:table-cell",children:e.jsx("p",{className:"text-foreground font-semibold text-xs",children:x(s.total)})}),e.jsx("td",{className:"px-4 py-3",onClick:r=>r.stopPropagation(),children:e.jsxs(T,{value:s.status,onValueChange:r=>S(s.id,r),disabled:v===s.id,children:[e.jsxs(I,{className:`h-7 text-xs px-2 border rounded-full w-28 ${P[s.status]}`,children:[e.jsx(O,{}),e.jsx(F,{size:11,className:"ml-auto shrink-0"})]}),e.jsxs(k,{children:[e.jsx(l,{value:"pending",children:"Pending"}),e.jsx(l,{value:"paid",children:"Paid"}),e.jsx(l,{value:"processing",children:"Processing"}),e.jsx(l,{value:"shipped",children:"Shipped"}),e.jsx(l,{value:"delivered",children:"Delivered"}),e.jsx(l,{value:"cancelled",children:"Cancelled"}),e.jsx(l,{value:"refunded",children:"Refunded"})]})]})}),e.jsx("td",{className:"px-4 py-3 hidden lg:table-cell",children:e.jsx("p",{className:"text-muted-foreground text-xs",children:D(s.createdAt)})}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsx("button",{onClick:r=>{r.stopPropagation(),C(s)},className:"text-xs text-primary hover:underline",children:"View"})})]},s.id))})]})})})]}),e.jsx(M,{open:!!t,onOpenChange:s=>!s&&u(null),children:e.jsxs(J,{className:"bg-card border-border/60 max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsx(q,{children:e.jsxs(G,{className:"text-foreground",children:["Order #",t==null?void 0:t.id]})}),t&&e.jsxs("div",{className:"space-y-4 text-sm",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground text-xs mb-0.5",children:"Customer"}),e.jsx("p",{className:"text-foreground",children:e.jsx(d,{devId:"1e9f3e",guard:{file:"src/pages/admin/orders.tsx",tagName:"p",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:5c04ebadf78c1e1d3f615c6c1befb6c667cc0ecffffd417029339fa07f1ad027"},children:t.customerName})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground text-xs mb-0.5",children:"Email"}),e.jsx("p",{className:"text-foreground text-xs",children:e.jsx(d,{devId:"30b7bf",guard:{file:"src/pages/admin/orders.tsx",tagName:"p",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionH
1ash:"sha256:2918dd1c06191f49f4402b4fd0ab4b009985f59c011b04cd8cfbdd723fd494c1"},children:t.customerEmail})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground text-xs mb-0.5",children:"Phone"}),e.jsx("p",{className:"text-foreground",children:e.jsx(d,{devId:"42d040",guard:{file:"src/pages/admin/orders.tsx",tagName:"p",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:c34858e344cc0082ab4a527e8852cc29c9679b64a2adbf58a0e0158361bae6bc"},children:t.customerPhone??"—"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground text-xs mb-0.5",children:"Company"}),e.jsx("p",{className:"text-foreground",children:e.jsx(d,{devId:"54e8c1",guard:{file:"src/pages/admin/orders.tsx",tagName:"p",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:ca58d56fdc7db57c300188205ebc488eb6e5a102d7891768007a23282f1bc0ee"},children:t.customerCompany??"—"})})]})]}),t.commerceOrderId&&e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground text-xs mb-0.5",children:"Commerce order ID"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-foreground font-mono text-xs bg-muted/30 rounded px-2 py-1 flex-1 truncate",children:e.jsx(d,{devId:"7b547e",guard:{file:"src/pages/admin/orders.tsx",tagName:"p",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:add13c864565c37234302bb64ceb6b3b93e3a4f5cec52b0e8f00e86debad0f9c"},children:t.commerceOrderId})}),e.jsx("a",{href:`https://payments.godaddy.com/orders/${t.commerceOrderId}`,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:text-primary/80","aria-label":"View in GoDaddy Payments",children:e.jsx(W,{size:13})})]})]}),t.shippingAddress&&e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground text-xs mb-0.5",children:"Shipping address"}),e.jsx("p",{className:"text-foreground text-xs bg-muted/30 rounded-lg p-2",children:e.jsx(d,{devId:"4a186c",guard:{file:"src/pages/admin/orders.tsx",tagName:"p",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:a378f06a12eb09989304737c1263b8b0da72e4b3dd2ef8436556eea831897092"},children:t.shippingAddress})})]}),L?e.jsx("div",{className:"py-4 text-center",children:e.jsx("div",{className:"w-5 h-5 border-2 border-primary border-t-transparent rounded-full animate-spin mx-auto"})}):t.items&&t.items.length>0?e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground text-xs mb-2",children:"Items"}),e.jsx("div",{className:"rounded-lg border border-border/40 overflow-hidden",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-muted/30 border-b border-border/40",children:[e.jsx("th",{className:"text-left px-3 py-2 text-muted-foreground font-medium",children:"Product"}),e.jsx("th",{className:"text-right px-3 py-2 text-muted-foreground font-medium",children:"Qty"}),e.jsx("th",{className:"text-right px-3 py-2 text-muted-foreground font-medium",children:"Total"})]})}),e.jsx("tbody",{children:t.items.map(s=>e.jsxs("tr",{className:"border-b border-border/30 last:border-b-0",children:[e.jsxs("td",{className:"px-3 py-2 text-foreground",children:[e.jsx("p",{children:s.productName}),s.sku&&e.jsxs("p",{className:"text-muted-foreground mt-0.5",children:["SKU: ",s.sku]})]}),e.jsx("td",{className:"px-3 py-2 text-right text-muted-foreground",children:s.quantity}),e.jsx("td",{className:"px-3 py-2 text-right text-foreground font-semibold",children:x(s.lineTotal)})]},s.id))})]})})]}):null,e.jsxs("div",{className:"rounded-lg bg-muted/20 p-3 space-y-1.5 text-xs",children:[e.jsxs("div",{className:"flex justify-between text-muted-foreground",children:[e.jsx("span",{children:"Subtotal"}),e.jsx("span",{children:e.jsx(d,{devId:"7e6225",guard:{file:"src/pages/admin/orders.tsx",tagName:"span",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:56b57bed569d6aee51db01f0296c458a7c1e674d017b69705fcadd54409bf47e"},children:x(t.subtotal)})})]}),e.jsxs("div",{className:"flex justify-between text-muted-foreground",children:[e.jsx("span",{children:"Tax"}),e.jsx("span",{children:e.jsx(d,{devId:"c03706",guard:{file:"src/pages/admin/orders.tsx",tagName:"span",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionH
1ash:"sha256:894a7925cfddf74f5f4eef4f27ce0d55b070362495ab4fed4f8cf18e2e424106"},children:x(t.tax)})})]}),e.jsxs("div",{className:"flex justify-between text-foreground font-bold border-t border-border/40 pt-1.5 mt-1.5",children:[e.jsx("span",{children:"Total"}),e.jsx("span",{children:e.jsx(d,{devId:"020be7",guard:{file:"src/pages/admin/orders.tsx",tagName:"span",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:cbe13141e668b47f1c4791d18768adc4ea8d905d2258e91174580af932f83e3f"},children:x(t.total)})})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-border/40",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"Status"}),e.jsx($,{className:`mt-1 text-xs border ${P[t.status]}`,children:t.status})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"Created"}),e.jsx("p",{className:"text-foreground text-xs mt-0.5",children:e.jsx(d,{devId:"5cf745",guard:{file:"src/pages/admin/orders.tsx",tagName:"p",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:d1b1e44fabd69e18dce10733a1299f0b3121b1439ef4a060bf768a7475a954cd"},children:D(t.createdAt)})})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2 pt-1",children:["pending","paid","processing","shipped","delivered","cancelled","refunded"].filter(s=>s!==t.status).map(s=>e.jsxs(K,{size:"sm",variant:"outline",disabled:v===t.id,onClick:()=>S(t.id,s),className:"text-xs border-border/60 text-muted-foreground hover:text-foreground capitalize",children:["Mark ",s]},s))})]})]})})]})}export{ce 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.