1import{c as V,j as e,h as B,u as K,e as _,r as n,a as h,C as H,S as q,L as z,l as J}from"./index-Kbt7gc3j.js";import{Q as X}from"./QuoteWorkbench-B_gHeOPE.js";import{g as Y,a as k,L as Z,c as ee}from"./LeadDrawer-GVFDHIIA.js";import{L as te}from"./layout-grid-B-WEbd7v.js";import{I as ae}from"./inbox-CadIPKUO.js";import"./refresh-cw-D1NI_C2F.js";import"./check-BoZVYvzb.js";import"./sliders-horizontal-Cx3B_Tts.js";import"./file-down-B9lJ8I_S.js";import"./send-DWxRRVhc.js";import"./credit-card-DQdmbA6_.js";import"./file-text-DyxyM9Q1.js";import"./auth-roles-CvtJqqkR.js";import"./alert-circle-BEtUEAjp.js";import"./upload-roxshKKb.js";import"./trash-2-l8pJjlj1.js";import"./image-5gt_BoMO.js";import"./file-spreadsheet-CjtPlTQ-.js";import"./building-2-B7wv1N15.js";import"./trending-up-DmdpzKK0.js";import"./message-square-6IeOHi1l.js";import"./mail-DDvIYqEa.js";import"./phone-DvtgOU2B.js";/** 2 * @license lucide-react v0.344.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const se=V("LayoutList",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["path",{d:"M14 4h7",key:"3xa0d5"}],["path",{d:"M14 9h7",key:"1icrd9"}],["path",{d:"M14 15h7",key:"1mj8o2"}],["path",{d:"M14 20h7",key:"11slyb"}]]);function re(o){if(!o)return"";const i=Date.now()-new Date(o).getTime(),g=Math.floor(i/6e4);if(g<60)return`${g}m`;const d=Math.floor(g/60);if(d<24)return`${d}h`;const x=Math.floor(d/24);if(x<30)return`${x}d`;const p=Math.floor(x/7);return p<9?`${p}w`:`${Math.floor(x/30)}mo`}function ne(o){const i=Number(o||0);return i?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(i):"â"}function oe(o){return o.guestCompany||o.guestName||o.guestEmail||"Lead"}const ie={NEW:"bg-gray-100 text-gray-600",CONTACTED:"bg-blue-100 text-blue-700",WORKING:"bg-indigo-100 text-indigo-700",QUOTED:"bg-yellow-100 text-yellow-700",NEGOTIATING:"bg-orange-100 text-orange-700",WON:"bg-green-100 text-green-700",LOST:"bg-red-100 text-red-700"};function le({leads:o,onMove:i,onOpen:g}){const d=Y(o),x=(s,c)=>{s.dataTransfer.setData("text/plain",c),s.dataTransfer.effectAllowed="move"},p=s=>{s.preventDefault(),s.dataTransfer.dropEffect="move"},w=(s,c)=>{s.preventDefault();const u=s.dataTransfer.getData("text/plain");if(!u)return;const a=o.find(y=>y.id===u);if(!a)return;(a.leadStatus&&k.includes(a.leadStatus)?a.leadStatus:"NEW")!==c&&i(u,c)};return e.jsx("div",{className:"flex gap-4 overflow-x-auto pb-4",children:k.map(s=>{const c=d[s]||[],u=ie[s]||"bg-gray-100 text-gray-600";return e.jsxs("div",{className:"flex-shrink-0 w-56 flex flex-col bg-gradient-to-b from-gray-50 to-slate-50/40 border border-gray-200 rounded-2xl overflow-hidden animate-fadeInUp",onDragOver:p,onDrop:a=>w(a,s),children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2.5 border-b border-gray-200 bg-white",children:[e.jsx("span",{className:"text-xs font-bold text-navy-900 uppercase tracking-wide",children:s}),e.jsx("span",{className:`text-xs font-bold px-1.5 py-0.5 rounded ${u}`,children:c.length})]}),e.jsx("div",{className:"flex flex-col gap-2 p-2 flex-1 min-h-[6rem]",children:c.map(a=>{const m=!!(a.nextTaskDueAt&&new Date(a.nextTaskDueAt)<new Date);return e.jsxs("div",{draggable:!0,onDragStart:y=>x(y,a.id),onClick:()=>g(a),className:"bg-white border border-gray-200 rounded-xl p-2.5 cursor-pointer hover:border-action-400 hover:shadow-md hover:-translate-y-0.5 transition-all duration-200 select-none",children:[e.jsxs("div",{className:"flex items-start justify-between gap-1",children:[e.jsx("p",{className:"text-xs font-semibold text-navy-900 leading-snug truncate flex-1",children:oe(a)}),m&&e.jsx("span",{className:"w-2 h-2 rounded-full bg-red-500 shrink-0 mt-0.5",title:"Overdue task"})]}),e.jsx("p",{className:"text-xs text-gray-700 tabular-nums mt-0.5 font-medium",children:ne(a.negotiatedTotal)}),a.createdAt&&e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:re(a.createdAt)})]},a.id)})})]},s)})})}function Oe(){const o=B(),{showToast:i}=K(),[g]=_(),[d,x]=n.useState([]),[p,w]=n.useState(!0),[s,c]=n.useState(null),u=n.useRef(null),[a,m]=n.useState(0),[y,D]=n.useState([]),[f,C]=n.useState("list"),[b,M]=n.useState(""),[v,E]=n.useState(""),[N,O]=n.useState("newest"),[I,T]=n.useState(null),[S,L]=n.useState(null);n.useEffect(()=>{g.get("focus")==="pool"&&u.current&&u.current.scrollIntoView({behavior:"smooth",block:"start"})},[]);const j=n.useCallback(async()=>{w(!0);try{x(await h.get("/quotes/pool")||[])}finally{w(!1)}},[]);n.useEffect(()=>{j()},[j]);const A=async t=>{c(t);try{await h.patch(`/quotes/${t}/claim`,{}),await j(),m(r=>r+1)}catch(r){i(r?.message||"Could not claim this lead â it may already be taken.","error"),await j()}finally{c(null)}};n.useEffect(()=>{const t={};b&&(t.q=b),v&&(t.leadStatus=v),N&&(t.sort=N);const Q=setTimeout(async()=>{try{const W=await h.get("/quotes/sales/mine?"+new URLSearchParams(t).toString());D(W||[])}catch{}},b?300:0);return()=>clearTimeout(Q)},[b,v,N,a]);const U=n.useCallback(()=>h.get("/quotes/sales/mine"),[a]),P=async(t,r)=>{await h.patch(`/quotes/${t}/lead-status`,{leadStatus:r}),m(l=>l+1)},$=async t=>{const r=await h.post("/quotes/manual",{...t,salespersonId:J.getUserId()});r?.warning&&i(r.warning,"info"),m(l=>l+1)},F=async(t,r)=>{if(r==="LOST"){L({id:t});return}try{await h.patch(`/quotes/${t}/lead-status`,{leadStatus:r}),m(l=>l+1)}catch(l){i(l?.message||"Failed to update stage.","error")}},R=async t=>{if(!S)return;const{id:r}=S;L(null);try{await h.patch(`/quotes/${r}/lead-status`,{leadStatus:"LOST",lostReason:t}),m(l=>l+1),i("Lead marked as lost.","info")}catch(l){i(l?.message||"Failed to mark as lost.","error")}},G=t=>
6{const r=Number(t.negotiatedTotal||0);return r?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(r):"â"};return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("section",{children:[e.jsxs("h2",{className:"text-lg font-bold text-navy-900 flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"w-8 h-8 rounded-lg bg-gradient-to-br from-action-500 to-orange-500 flex items-center justify-center shadow-md shadow-action-500/25",children:e.jsx(H,{className:"w-4 h-4 text-white"})})," My Quotes"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-4",children:[e.jsxs("div",{className:"flex rounded-md border border-gray-200 overflow-hidden shrink-0",children:[e.jsxs("button",{onClick:()=>C("list"),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium transition-colors cursor-pointer "+(f==="list"?"bg-navy-900 text-white":"bg-white text-gray-600 hover:bg-gray-50"),"aria-pressed":f==="list",children:[e.jsx(se,{className:"w-4 h-4"}),"List"]}),e.jsxs("button",{onClick:()=>C("board"),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium transition-colors cursor-pointer border-l border-gray-200 "+(f==="board"?"bg-navy-900 text-white":"bg-white text-gray-600 hover:bg-gray-50"),"aria-pressed":f==="board",children:[e.jsx(te,{className:"w-4 h-4"}),"Board"]})]}),f==="board"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative flex-1 min-w-[160px]",children:[e.jsx(q,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 pointer-events-none"}),e.jsx("input",{type:"search",value:b,onChange:t=>M(t.target.value),placeholder:"Search leadsâ¦",className:"w-full pl-8 pr-3 py-1.5 text-sm border border-gray-200 rounded-md bg-white text-navy-900 placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-action-600"})]}),e.jsxs("select",{value:v,onChange:t=>E(t.target.value),className:"border border-gray-200 rounded-md px-2.5 py-1.5 text-sm text-navy-900 bg-white cursor-pointer focus:outline-none focus:ring-2 focus:ring-action-600",children:[e.jsx("option",{value:"",children:"All Stages"}),k.map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsxs("select",{value:N,onChange:t=>O(t.target.value),className:"border border-gray-200 rounded-md px-2.5 py-1.5 text-sm text-navy-900 bg-white cursor-pointer focus:outline-none focus:ring-2 focus:ring-action-600",children:[e.jsx("option",{value:"newest",children:"Newest"}),e.jsx("option",{value:"value",children:"Value"})]})]})]}),f==="list"?e.jsx(X,{scope:"SALES",fetchQuotes:U,emptyHint:"Claim a lead from the Unassigned Leads below to start working a quote.",onPaid:()=>o("/salesteam?celebrate=1"),onUpdateLeadStatus:P,newLeadMode:!0,onSendNewLead:$},a):e.jsx(le,{leads:y,onMove:F,onOpen:T})]}),e.jsxs("section",{ref:u,children:[e.jsxs("h2",{className:"text-lg font-bold text-navy-900 flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"w-8 h-8 rounded-lg bg-gradient-to-br from-indigo-500 to-violet-600 flex items-center justify-center shadow-md shadow-indigo-500/25",children:e.jsx(ae,{className:"w-4 h-4 text-white"})})," Unassigned Leads",e.jsx("span",{className:"text-xs font-bold bg-navy-100 text-navy-600 px-2 py-0.5 rounded-full",children:d.length})]}),p?e.jsx("div",{className:"h-24 bg-white rounded-xl animate-pulse border border-navy-200"}):d.length===0?e.jsx("p",{className:"text-sm text-navy-500 bg-white border border-navy-200 rounded-xl p-4",children:"No unclaimed leads right now. Nice work! ð"}):e.jsx("div",{className:"bg-white border border-navy-200 rounded-xl shadow-card divide-y divide-navy-100 overflow-hidden",children:d.map(t=>e.jsxs("div",{className:"flex items-center justify-between p-4 hover:bg-navy-50 transition-colors",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-navy-900",children:t.guestCompany||t.guestName||t.user?.email||"New lead"}),e.jsxs("p",{className:"text-xs text-navy-500",children:[t.referenceNumber," · ",t.type," · ",G(t)]})]}),e.jsxs("button",{onClick:()=>A(t.id),disabled:s===t.id,className:"px-3 py-1.5 bg-action-500 text-white text-sm font-bold rounded-lg hover:bg-action-600 disabled:opacity-50 transition-colors cursor-pointer inline-flex items-center gap-1.5",children:[s===t.id&&e.jsx(z,{className:"w-3.5 h-3.5 animate-spin"}),s===t.id?"Claimingâ¦":"Claim"]})]},t.id))})]}),e.jsx(Z,{lead:I,onClose:()=>T(null),onChanged:()=>m(t=>t+1)}),e.jsx(ee,{open:!!S,onCancel:()=>L(null),onConfirm:R})]})}export{Oe 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.