1import{u as H,h as T,a as u,j as t,L as x}from"./vendor-react-DQmRrvQV.js";import{l as R}from"./vendor-state-3t2mugU9.js";import{c as U,h as l,D as w}from"./DashboardDatePicker-CdNDQNkI.js";import{e as I}from"./dashboard-DT7abwiX.js";import{a7 as j,aI as P}from"./index-Cn9rYaym.js";import{S as C}from"./StandardBadge-BpGdLBVj.js";import{T as A,a as O}from"./TableContainer-CYHVIWle.js";import{T as V}from"./TableHeader-CrEWoyFa.js";import{P as q}from"./PageTitle-a6p5JUJv.js";import"./vendor-mui-BxA0N6WT.js";import"./floating-ui.dom-CDmV5yS9.js";import"./sse-B8JMfTht.js";import"./Spinner-D3-9kPSi.js";const L={draft:{label:"Draft",variant:"secondary"},pending_review:{label:"Pending Review",variant:"warning"},sent:{label:"Sent",variant:"primary"},viewed:{label:"Viewed",variant:"warning"},accepted:{label:"Accepted",variant:"success"},rejected:{label:"Rejected",variant:"danger"}},$={hot:{label:"Hot",variant:"danger"},warm:{label:"Warm",variant:"warning"},cold:{label:"Cold",variant:"info"}},D=(s,m)=>s==null?"-":new Intl.NumberFormat("en-US",{style:"currency",currency:m??"USD",minimumFractionDigits:0,maximumFractionDigits:2}).format(s),v=s=>s==null?"-":s<60?`${s}s`:s<3600?`${Math.floor(s/60)}m`:`${Math.floor(s/3600)}h ${Math.floor(s%3600/60)}m`,Q=s=>{const y=[["Date Sent","Contact Name","Company","Email Address","Quote Value","Currency","Line Items","Valid Until","Priority","Quote Status","Viewed At","Response Time","Days Since Sent"].join(","),...s.map(n=>[n.dateSent?l(n.dateSent).format("YYYY-MM-DD HH:mm"):"",`"${n.contactName??""}"`,`"${n.company??""}"`,n.email??"",n.quoteValue??"",n.currency??"",n.lineItemCount??"",n.validUntil?l(n.validUntil).format("YYYY-MM-DD"):"",n.priority??"",`"${n.fields?Object.entries(n.fields).filter(([,i])=>i!=null).map(([i,p])=>`${i}: ${p}`).join("; "):""}"`,n.quoteStatus??"",n.viewedAt?l(n.viewedAt).format("YYYY-MM-DD HH:mm"):"Not opened",v(n.responseTimeSeconds),n.daysSinceSent??""].join(","))],c=new Blob([y.join(` 2`)],{type:"text/csv"}),d=URL.createObjectURL(c),r=document.createElement("a");r.href=d,r.download=`quotes-sent-${l().format("YYYY-MM-DD")}.csv`,r.click(),URL.revokeObjectURL(d)},te=()=>{var b;const s=H(),m=T(),c=(s.state??{}).preset??"TODAY",d=U(c)??{},[r,n]=u.useState({preset:c,from:d.from??null,to:d.to??null}),[i,p]=u.useState(""),g=u.useMemo(()=>r.preset==="CUSTOM"?{range:"CUSTOM",from:r.from?new Date(r.from).toISOString():void 0,to:r.to?new Date(r.to).toISOString():void 0}:{range:r.preset??"TODAY"},[r]),{data:o,isLoading:M}=R({queryKey:["report-quotes-sent",g,i],queryFn:()=>I({...g,search:i,limit:100}),select:e=>e.data??{}}),f=(o==null?void 0:o.data)??[],S=(o==null?void 0:o.meta)??{},h=((b=o==null?void 0:o.pagination)==null?void 0:b.total)??null,Y=u.useMemo(()=>[{Header:"Date Sent",accessor:"dateSent",Cell:({value:e})=>e?l(e).format("MMM D, h:mm A"):"-"},{Header:"Contact Name",accessor:"contactName",Cell:({value:e,row:a})=>t.jsx(x,{to:j(a.original.leadId),className:"fw-semibold table-link",children:e||"-"})},{Header:"Company",accessor:"company",Cell:({value:e})=>e||"-"},{Header:"Email Address",accessor:"email"},{Header:"Quote Value",accessor:"quoteValue",Cell:({value:e,row:a})=>t.jsx(x,{to:P(a.original.id),className:"fw-semibold table-link",children:D(e,a.original.currency)})},{Header:"Currency",accessor:"currency",Cell:({value:e})=>e||"-"},{Header:"Line Items",accessor:"lineItemCount",Cell:({value:e})=>e??"-"},{Header:"Valid Until",accessor:"validUntil",Cell:({value:e})=>
2{if(!e)return"-";const a=new Date(e)<new Date;return t.jsxs("span",{style:{color:a?"#dc3545":void 0,fontWeight:a?600:void 0,whiteSpace:"nowrap"},children:[l(e).format("MMM D, YYYY"),a&&t.jsx("span",{className:"ms-1",style:{fontSize:11},children:"(expired)"})]})}},{Header:"Priority",accessor:"priority",Cell:({value:e})=>{const a=$[e];return a?t.jsx(C,{label:a.label,variant:a.variant}):"-"}},{Header:"Quote Status",accessor:"quoteStatus",Cell:({value:e})=>{const a=L[e]??{label:e,variant:"secondary"};return t.jsx(C,{label:a.label,variant:a.variant})}},{Header:"Viewed At",accessor:"viewedAt",Cell:({value:e})=>e?t.jsx("span",{style:{whiteSpace:"nowrap"},children:l(e).format("MMM D, h:mm A")}):t.jsx("span",{className:"text-muted fst-italic",children:"Not yet opened"})},{Header:"Response Time",accessor:"responseTimeSeconds",Cell:({value:e})=>{const a=e!=null&&e>3600;return t.jsx("span",{style:{color:a?"#dc3545":void 0,fontWeight:a?600:void 0},children:v(e)})}},{Header:"Days Since Sent",accessor:"daysSinceSent",Cell:({value:e})=>{const a=e!=null&&e>3;return t.jsx("span",{style:{color:a?"#dc3545":void 0,fontWeight:a?600:void 0},children:e!=null?`${e}d`:"-"})}},{Header:"Follow Up",id:"followUp",disableSortBy:!0,Cell:({row:e})=>e.original.daysSinceSent>3&&e.original.quoteStatus==="sent"?t.jsx("span",{title:"Sent > 3 days ago, not yet opened",style:{cursor:"default"},children:t.jsx("i",{className:"mdi mdi-bell-alert text-danger"})}):t.jsx("span",{className:"text-muted",children:"-"})}],[]);return t.jsxs("div",{className:"page-content",children:[t.jsx(q,{title:"Quotes Sent",actions:t.jsx(w,{initialPreset:c,onApply:({preset:e,from:a,to:N})=>n({preset:e,from:a,to:N})})}),t.jsxs(A,{children:[t.jsx(V,{searchValue:i,onSearchChange:p,searchPlaceholder:"Search name, company, email...",rightContent:t.jsxs("button",{className:"btn btn-sm btn-outline-secondary",onClick:()=>Q(f),disabled:f.length===0,children:[t.jsx("i",{className:"mdi mdi-download me-1"}),"Export CSV"]})}),h!=null&&t.jsxs("p",{className:"text-muted mb-2 px-1",style:{fontSize:13},children:["Showing ",h," quote",h!==1?"s":"",S.totalPipelineValue>0&&t.jsxs(t.Fragment,{children:[" · Total Pipeline: ",t.jsx("span",{className:"fw-semibold",children:D(S.totalPipelineValue,S.currency)})]})]}),t.jsx(O,{columns:Y,data:f,loading:M,emptyMsg:"No quotes found for this period.",emptyIcon:"mdi-file-document-outline",pageSize:10,defaultSortBy:[{id:"dateSent",desc:!0}],onRowClick:e=>m(j(e.leadId))})]})]})};export{te 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.