1import{a as n,j as e}from"./query-Ban24u4e.js";import{u as E,H as Q,F as d,B as T,X as U,a as z}from"./index-jvhwSSW_.js";import{A as $,F as O}from"./AdminLayout-D4fzZ2x1.js";import{I as q}from"./input-DcaHre60.js";import{R as F,S as A,a as D,b as k,c as H,d as l,C as R,D as B,e as _,f as M,g as J}from"./dialog-UeF9Ts51.js";import{S as W}from"./search-D8Je0oyf.js";import"./radix-ui-DdasXo-Q.js";import"./users-Bq-EBKxW.js";import"./chevron-right-Bm_-M2lJ.js";import"./check-Dcx7_PRd.js";const I={draft:"bg-muted text-muted-foreground border-border/60",sent:"bg-blue-500/10 text-blue-400 border-blue-500/20",accepted:"bg-emerald-500/10 text-emerald-400 border-emerald-500/20",declined:"bg-red-500/10 text-red-400 border-red-500/20",expired:"bg-yellow-500/10 text-yellow-400 border-yellow-500/20"},X=[{value:"all",label:"All statuses"},{value:"draft",label:"Draft"},{value:"sent",label:"Sent"},{value:"accepted",label:"Accepted"},{value:"declined",label:"Declined"},{value:"expired",label:"Expired"}];function g(c){return new Date(c).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function o(c){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(Number(c))}function le(){const[c,L]=E(),[P,h]=n.useState([]),[j,N]=n.useState(!0),[m,y]=n.useState(""),[s,u]=n.useState(null),[V,v]=n.useState(!1),[w,C]=n.useState(null),p=c.get("status")??"all",f=n.useCallback(async()=>{N(!0);try{const t=p!=="all"?`/api/quotes?status=${p}`:"/api/quotes",a=await fetch(t).then(r=>r.json());h(Array.isArray(a)?a:[])}catch{h([])}finally{N(!1)}},[p]);n.useEffect(()=>{f()},[f]);const S=async t=>{if(u(t),!t.items){v(!0);try{const a=await fetch(`/api/quotes?id=${t.id}`).then(r=>r.json());u(a)}catch{}finally{v(!1)}}},K=(t,a)=>{C(t),fetch(`/api/quotes/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:a})}).then(r=>r.json()).then(r=>{h(x=>x.map(b=>b.id===t?{...b,status:r.status}:b)),(s==null?void 0:s.id)===t&&u(x=>x&&{...x,status:r.status})}).catch(()=>{}).finally(()=>C(null))},i=P.filter(t=>{if(!m)return!0;const a=m.toLowerCase();return t.quoteNumber.toLowerCase().includes(a)||t.customerName.toLowerCase().includes(a)||t.customerEmail.toLowerCase().includes(a)||(t.customerCompany??"").toLowerCase().includes(a)||(t.serviceType??"").toLowerCase().includes(a)});return e.jsxs($,{children:[e.jsxs(Q,{children:[e.jsx("title",{children:"Quotes â CTVCam Admin"}),e.jsx("meta",{name:"description",content:"Manage installation quotes for CTVCam."}),e.jsx("link",{rel:"canonical",href:"https://ctvcam.com/admin/quotes"}),e.jsx("meta",{name:"robots",content:"noindex, nofollow"}),e.jsx("meta",{property:"og:title",content:"Quotes â CTVCam Admin"}),e.jsx("meta",{property:"og:description",content:"Manage installation quotes 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/quotes"}),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:"Quotes â CTVCam Admin",url:"https://ctvcam.com/admin/quotes",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:"Quotes"}),e.jsx("p",{className:"text-muted-foreground text-sm mt-0.5",children:e.jsx(d,{devId:"98cd32",guard:{file:"src/pages/admin/quotes.tsx",tagName:"p",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:638f94264b9b301342ff4d02285a69dadf5b2aee51b493b83f131bbb1b8c1f12"},children:j?"Loadingâ¦":`${i.length} quote${i.length!==1?"s":""}`})})]}),e.jsxs(T,{variant:"outline",size:"sm",onClick:f,className:"border-border text-muted-foreground hover:text-foreground gap-1.5",children:[e.jsx(F,{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(W,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e.jsx(q,{value:m,onChange:t=>y(t.target.value),placeholder:"Search quotesâ¦",className:"pl-8 pr-8 bg-card border-border/60 text-foreground placeholder:text-muted-foreground text-sm"}),m&&e.jsx("button",{onClick:()=>y(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground","aria-label":"Clear search",children:e.jsx(U,{size:13})})]}),e.jsxs(A,{value:p,onValueChange:t=>L(t==="all"?{}:{status:t}),children:[e.jsx(D,{className:"w-44 bg-card border-border/60 text-foreground text-sm",children:e.jsx(k,{})}),e.jsx(H,{children:X.map(t=>e.jsx(l,{value:t.value,children:t.label},t.value))})]})]}),e.jsx("div",{className:"rounded-xl border border-border/60 bg-card overflow-hidden",children:j?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"})}):i.length===0?e.jsxs("div",{className:"p-12 text-center",children:[e.jsx(O,{size:36,className:"text-muted-foreground/30 mx-auto mb-3"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"No quotes 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:"Quote #"}),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 md:table-cell",children:"Service"}),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:i.map((t,a)=>e.jsxs("tr",{className:`border-b border-border/40 hover:bg-muted/20 transition-colors cursor-pointer ${a===i.length-1?"border-b-0":""}`,onClick:()=>S(t),children:[e.jsx("td",{className:"px-4 py-3",children:e.jsx("p",{className:"text-foreground font-mono text-xs font-semibold",children:t.quoteNumber})}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("p",{className:"text-foreground font-medium",children:t.customerName}),e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:t.customerEmail})]}),e.jsx("td",{className:"px-4 py-3 hidden md:table-cell",children:e.jsx("p",{className:"text-muted-foreground text-xs",children:t.serviceType??"â"})}),e.jsx("td",{className:"px-4 py-3 hidden sm:table-cell",children:e.jsx("p",{className:"text-foreground font-semibold text-xs",children:o(t.total)})}),e.jsx("td",{className:"px-4 py-3",onClick:r=>r.stopPropagation(),children:e.jsxs(A,{value:t.status,onValueChange:r=>K(t.id,r),disabled:w===t.id,children:[e.jsxs(D,{className:`h-7 text-xs px-2 border rounded-full w-28 ${I[t.status]}`,children:[e.jsx(k,{}),e.jsx(R,{size:11,className:"ml-auto shrink-0"})]}
1),e.jsxs(H,{children:[e.jsx(l,{value:"draft",children:"Draft"}),e.jsx(l,{value:"sent",children:"Sent"}),e.jsx(l,{value:"accepted",children:"Accepted"}),e.jsx(l,{value:"declined",children:"Declined"}),e.jsx(l,{value:"expired",children:"Expired"})]})]})}),e.jsx("td",{className:"px-4 py-3 hidden lg:table-cell",children:e.jsx("p",{className:"text-muted-foreground text-xs",children:g(t.createdAt)})}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsx("button",{onClick:r=>{r.stopPropagation(),S(t)},className:"text-xs text-primary hover:underline",children:"View"})})]},t.id))})]})})})]}),e.jsx(B,{open:!!s,onOpenChange:t=>!t&&u(null),children:e.jsxs(_,{className:"bg-card border-border/60 max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsx(M,{children:e.jsx(J,{className:"text-foreground font-mono text-base",children:s==null?void 0:s.quoteNumber})}),s&&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:"533290",guard:{file:"src/pages/admin/quotes.tsx",tagName:"p",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:5c04ebadf78c1e1d3f615c6c1befb6c667cc0ecffffd417029339fa07f1ad027"},children:s.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:"654b11",guard:{file:"src/pages/admin/quotes.tsx",tagName:"p",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:2918dd1c06191f49f4402b4fd0ab4b009985f59c011b04cd8cfbdd723fd494c1"},children:s.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:"776392",guard:{file:"src/pages/admin/quotes.tsx",tagName:"p",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:c34858e344cc0082ab4a527e8852cc29c9679b64a2adbf58a0e0158361bae6bc"},children:s.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:"897c13",guard:{file:"src/pages/admin/quotes.tsx",tagName:"p",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:ca58d56fdc7db57c300188205ebc488eb6e5a102d7891768007a23282f1bc0ee"},children:s.customerCompany??"â"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground text-xs mb-0.5",children:"Service type"}),e.jsx("p",{className:"text-foreground",children:e.jsx(d,{devId:"9b9494",guard:{file:"src/pages/admin/quotes.tsx",tagName:"p",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:5d1e46ef766dbba0c330d6b26bdbd7190fb8d192201b643d0608ace19758cb38"},children:s.serviceType??"â"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground text-xs mb-0.5",children:"Valid until"}),e.jsx("p",{className:"text-foreground",children:e.jsx(d,{devId:"adad15",guard:{file:"src/pages/admin/quotes.tsx",tagName:"p",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:0cd196d1b4488ff7714dc7490325e114b74177c97f169ed704f7a7a2cbb6b011"},children:s.validUntil?g(s.validUntil):"â"})})]})]}),s.siteAddress&&e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground text-xs mb-0.5",children:"Site address"}),e.jsx("p",{className:"text-foreground text-xs bg-muted/30 rounded-lg p-2",children:e.jsx(d,{devId:"1cfdbd",guard:{file:"src/pages/admin/quotes.tsx",tagName:"p",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:88fd7d4141cf96e836e009bf9d57d386f58d92fdd6ea6aaf24f30640763b89e1"},children:s.siteAddress})})]}),V?e.jsx("div",{className:"py-4 text-center",children:e.jsx("div",{className:"w-5 h-5 border-2 border-primary border-t-transparent roun
1ded-full animate-spin mx-auto"})}):s.items&&s.items.length>0?e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground text-xs mb-2",children:"Line 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:"Description"}),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:"Unit"}),e.jsx("th",{className:"text-right px-3 py-2 text-muted-foreground font-medium",children:"Total"})]})}),e.jsx("tbody",{children:s.items.map(t=>e.jsxs("tr",{className:"border-b border-border/30 last:border-b-0",children:[e.jsx("td",{className:"px-3 py-2 text-foreground",children:t.description}),e.jsx("td",{className:"px-3 py-2 text-right text-muted-foreground",children:t.quantity}),e.jsx("td",{className:"px-3 py-2 text-right text-muted-foreground",children:o(t.unitPrice)}),e.jsx("td",{className:"px-3 py-2 text-right text-foreground font-semibold",children:o(t.lineTotal)})]},t.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:"bad296",guard:{file:"src/pages/admin/quotes.tsx",tagName:"span",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:56b57bed569d6aee51db01f0296c458a7c1e674d017b69705fcadd54409bf47e"},children:o(s.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:"fca777",guard:{file:"src/pages/admin/quotes.tsx",tagName:"span",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:894a7925cfddf74f5f4eef4f27ce0d55b070362495ab4fed4f8cf18e2e424106"},children:o(s.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:"3e7c58",guard:{file:"src/pages/admin/quotes.tsx",tagName:"span",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:cbe13141e668b47f1c4791d18768adc4ea8d905d2258e91174580af932f83e3f"},children:o(s.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(z,{className:`mt-1 text-xs border ${I[s.status]}`,children:s.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:"34d556",guard:{file:"src/pages/admin/quotes.tsx",tagName:"p",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:d1b1e44fabd69e18dce10733a1299f0b3121b1439ef4a060bf768a7475a954cd"},children:g(s.createdAt)})})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2 pt-1",children:["draft","sent","accepted","declined","expired"].filter(t=>t!==s.status).map(t=>e.jsxs(T,{size:"sm",variant:"outline",disabled:w===s.id,onClick:()=>K(s.id,t),className:"text-xs border-border/60 text-muted-foreground hover:text-foreground capitalize",children:["Mark ",t]},t))})]})]})})]})}export{le 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.