PageSourceSearch

https://australiancleaningcare.com.au/assets/StaffPipelinePage-B-6x3TBv.js

js australiancleaningcare.com.au collected 2026-10-06 21:04:06 UTC 31,027 bytes, 5 lines download raw bytes

1import{f as x,L as e}from"./react-vendor-DqSQso5U.js";import{u as ue}from"./useRealtimePipeline-2jEZqA44.js";import{f as xe,b as pe,B as d}from"./index-Dl7eX50H.js";import{supabase as P}from"./client-CiNs00sj.js";import{I as se}from"./input-ObhYebZl.js";import{S as H,a as B,b as V,c as G,d as C}from"./select-Djd-6Eeq.js";import{D as he,a as fe,b as ge,c as be}from"./dialog-Bmz_ZrqP.js";import{T as je}from"./textarea-BHVoRXuH.js";import{S as ye}from"./StaffNavBar-jX2TaB6v.js";import{l as ee}from"./auditLog-DezC4_68.js";import{aA as le,E as q,v as we,g as ae,aS as ne,t as _e,T as W,aT as te,f as Y,N as k,aO as E,u as J,aU as oe,$ as ie,aV as Ne}from"./icons-vendor-qFcwiy8S.js";const re=[{key:"Lead",label:"Lead",color:"bg-gray-100 text-gray-700 border-gray-300"},{key:"Inspection Scheduled",label:"Inspection Scheduled",color:"bg-blue-50 text-blue-700 border-blue-300"},{key:"Quote Sent",label:"Quote Sent",color:"bg-yellow-50 text-yellow-700 border-yellow-300"},{key:"Follow Up",label:"Follow Up",color:"bg-orange-50 text-orange-700 border-orange-300"},{key:"Contract Won",label:"Contract Won",color:"bg-green-50 text-green-700 border-green-300"},{key:"Contract Lost",label:"Contract Lost",color:"bg-red-50 text-red-700 border-red-300"}],U={Lead:"bg-gray-200 text-gray-800","Inspection Scheduled":"bg-blue-100 text-blue-800","Quote Sent":"bg-yellow-100 text-yellow-800","Follow Up":"bg-orange-100 text-orange-800","Contract Won":"bg-green-100 text-green-800","Contract Lost":"bg-red-100 text-red-800"},ve=["sydney cbd","cbd","parramatta","north sydney","barangaroo","chatswood","macquarie park"],Se=["medical","corporate office","strata"];function K(s){const o=(s.address||"").toLowerCase(),i=(s.facility_type||"").toLowerCase(),u=s.estimated_price_high||s.estimated_price_low||0,a=ve.some(f=>o.includes(f)),r=Se.some(f=>i.includes(f)),p=Number(u)>=3e3;return a&&r||p||a&&p?{label:"🔥 HOT",color:"bg-red-100 text-red-800 border-red-300"}:a||r?{label:"⚡ WARM",color:"bg-yellow-100 text-yellow-800 border-yellow-300"}:{label:"❄ COLD",color:"bg-slate-100 text-slate-600 border-slate-300"}}function X(s){if(s.status==="Contract Won")return 100;if(s.status==="Contract Lost")return 0;let i={Lead:10,"Inspection Scheduled":25,"Quote Sent":45,"Follow Up":35}[s.status]??15;const u=K(s);u.label.includes("HOT")?i+=25:u.label.includes("WARM")&&(i+=10);const a=[s.facility_type,s.address,s.cleaning_frequency,s.estimated_price_low||s.estimated_price_high].filter(Boolean).length;return i+=a*3,s.client_replied&&(i+=15),s.inspection_date&&(i+=10),(s.follow_up_stage||0)>=5&&!s.client_replied&&(i-=10),(s.follow_up_stage||0)>=7&&!s.client_replied&&(i-=10),Math.max(5,Math.min(95,Math.round(i)))}function ce(s){return s>=70?"bg-green-100 text-green-800 border-green-300":s>=40?"bg-yellow-100 text-yellow-800 border-yellow-300":"bg-slate-100 text-slate-600 border-slate-300"}function de(s){if(s.status==="Lead"){const o=Math.floor((Date.now()-new Date(s.created_at).getTime())/6e4);return o<30?{label:`${o}m`,color:"text-green-600",minutes:o}:o<120?{label:`${Math.floor(o/60)}h ${o%60}m`,color:"text-yellow-600",minutes:o}:{label:`${Math.floor(o/60)}h`,color:"text-red-600",minutes:o}}return null}const Ce=["Price too high","Chose competitor","Bad timing / not ready","No response","Internal cleaning","Budget cut","Other"],ke=[{label:"Price",response:"We focus on reliability, compliance, and supervisor-managed service — not just the lowest price. Our contracts include full reporting, quality audits, and dedicated supervision at no extra cost."},{label:"Switching",response:"We handle the entire transition with zero disruption. Our supervisor manages the handover on-site, and most clients see improved results within the first week."},{label:"Contract",response:"Our agreements are flexible — we don't lock you in. We earn your business every month through consistent quality and transparent reporting."},{label:"Size",response:"We service everything from single-floor offices to multi-level commercial buildings. We tailor the scope and team size to match your facility."}],Le=[{title:"1. Introduction",content:"Hi, this is [Name] from Australian Cleaning Care. I'm following up on your cleaning quote request — is now a good time?"},{title:"2. Qualify",content:`Can I confirm a few details?
2• What type of facility is this? (office / medical / strata)
3• Approximately how large is the space?
4• How often do you need cleaning?
5• What's your main frustration with your current provider?`},{title:"3. Position",content:"We handle similar [facility type] facilities across [suburb]. Every contract includes a dedicated site supervisor, digital audit reports, and full compliance documentation."},{title:"4. Authority",content:"We're aligned with ISO 9001, HACCP, and WHS standards. All our teams are police-checked, and we carry $20M public liability insurance."},{title:"5. Close",content:"Would you prefer us to come for a site inspection this week or next? It takes about 15 minutes and there's no obligation."}];function $e(s){const o=[],i=new Date().toISOString().split("T")[0];for(const a of s)if(!(a.status==="Contract Won"||a.status==="Contract Lost")&&(a.follow_up_enabled&&!a.client_replied&&!a.follow_up_paused&&a.follow_up_next_at&&a.follow_up_next_at.split("T")[0]<=i&&o.push({record:a,reason:`Follow-up ${(a.follow_up_stage||0)+1} overdue`,priority:"high",action:"Send follow-up email"}),a.status==="Inspection Scheduled"&&a.inspection_booked_at&&!a.quote_sent_at&&Math.floor((Date.now()-new Date(a.inspection_booked_at).getTime())/864e5)>=1&&o.push({record:a,reason:"Inspection scheduled but no proposal sent",priority:"high",action:"Generate proposal from inspection"}),a.client_replied&&(a.status==="Quote Sent"||a.status==="Follow Up")&&o.push({record:a,reason:"Client replied — update pipeline status",priority:"medium",action:"Review and update status"}),a.status==="Quote Sent"&&!a.follow_up_enabled&&!a.client_replied&&a.follow_up_stage===0&&o.push({record:a,reason:"Quote sent but no follow-up scheduled",priority:"medium",action:"Enable follow-ups or contact client"}),(a.email_delivery_status==="failed"||a.status==="Quote Sent"&&a.follow_up_status==="Email delivery failed")&&o.push({record:a,reason:`Client email delivery failed${a.client_email_error?`: ${a.client_email_error}`:""}`,priority:"high",action:"Resend proposal or contact client directly"}),a.status==="Lead")){const r=Math.floor((Date.now()-new Date(a.created_at).getTime())/864e5);r>=7&&o.push({record:a,reason:`Lead inactive for ${r} days`,priority:"low",action:"Schedule inspection or contact lead"})}const u={high:0,medium:1,low:2};return o.sort((a,r)=>u[a.priority]-u[r.priority]),o}const ze=()=>{const s=xe(),[o,i]=x.useState([]),[u,a]=x.useState(!0),[r,p]=x.useState(null),[f,z]=x.use
5State("all"),[L,j]=x.useState(""),[v,y]=x.useState(null),g=x.useCallback(async()=>{a(!0);const{data:t,error:n}=await P.from("sales_pipeline").select("*").order("created_at",{ascending:!1});!n&&t&&i(t),a(!1)},[]);x.useEffect(()=>{g()},[g]),ue(g);const $=new Date().toISOString().split("T")[0],w=o.filter(t=>t.follow_up_enabled&&!t.client_replied&&!t.follow_up_paused&&t.follow_up_next_at&&t.follow_up_next_at.split("T")[0]<=$&&t.status!=="Contract Won"&&t.status!=="Contract Lost"),_=$e(o),T=o.filter(t=>{if(f!=="all"&&t.status!==f)return!1;if(L){const n=L.toLowerCase();return t.company_name.toLowerCase().includes(n)||t.contact_name.toLowerCase().includes(n)||(t.email||"").toLowerCase().includes(n)}return!0}),b=new Date;b.setDate(1);const A=b.toISOString(),h=o.filter(t=>t.created_at>=A),m={leads:h.filter(t=>t.status==="Lead").length,inspections:h.filter(t=>t.status==="Inspection Scheduled").length,quotesSent:h.filter(t=>["Quote Sent","Follow Up"].includes(t.status)).length,won:h.filter(t=>t.status==="Contract Won").length,lost:h.filter(t=>t.status==="Contract Lost").length,followUpToday:w.length,needsAction:_.length},N=m.won+m.lost,D=N>0?Math.round(m.won/N*100):0,I=["Lead","Inspection Scheduled","Quote Sent","Follow Up"],R=o.filter(t=>I.includes(t.status)).reduce((t,n)=>{const Z=(Number(n.estimated_price_high)||Number(n.estimated_price_low)||0)*12,me=X(n)/100;return t.weighted+=Z*me,t.gross+=Z,t},{weighted:0,gross:0}),O=t=>t>=1e6?`$${(t/1e6).toFixed(1)}M`:t>=1e3?`$${Math.round(t/1e3)}k`:`$${Math.round(t)}`,S=async(t,n)=>{y(t),await P.from("sales_pipeline").update(n).eq("id",t),await g(),y(null),(r==null?void 0:r.id)===t&&p(Q=>Q?{...Q,...n}:null)},F=async t=>{y(t.id);const n=Math.min((t.follow_up_stage||0)+1,7);await P.functions.invoke("send-follow-up-now",{body:{pipelineId:t.id,stage:n}}),await g(),y(null)},l=t=>t?new Date(t).toLocaleDateString("en-AU",{day:"numeric",month:"short",year:"numeric"}):"—",c=t=>{if(!t)return"";const n=Math.floor((Date.now()-new Date(t).getTime())/864e5);return n===0?"today":n===1?"1 day ago":`${n} days ago`},M={high:"bg-red-100 text-red-800",medium:"bg-yellow-100 text-yellow-800",low:"bg-gray-100 text-gray-700"};return e.jsxs(e.Fragment,{children:[e.jsxs(pe,{children:[e.jsx("meta",{name:"robots",content:"noindex, nofollow"}),e.jsx("title",{children:"Sales Pipeline — ACC Staff"})]}),e.jsxs("div",{className:"min-h-screen bg-muted/30",children:[e.jsx(ye,{title:"Sales Pipeline"}),e.jsxs("main",{className:"container max-w-7xl py-6 px-4 space-y-6",children:[e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-8 gap-3",children:[{label:"Leads",value:m.leads,icon:le,color:"text-gray-600"},{label:"Inspections",value:m.inspections,icon:q,color:"text-blue-600"},{label:"Quotes Sent",value:m.quotesSent,icon:we,color:"text-yellow-600"},{label:"Won",value:m.won,icon:ae,color:"text-green-600"},{label:"Lost",value:m.lost,icon:ne,color:"text-red-600"},{label:"Conversion",value:`${D}%`,icon:_e,color:"text-primary"},{label:"Follow-ups",value:m.followUpToday,icon:W,color:"text-orange-600"},{label:"Needs Action",value:m.needsAction,icon:te,color:"text-red-600"}].map(t=>e.jsxs("div",{className:"bg-card rounded-lg border border-border p-3 text-center",children:[e.jsx(t.icon,{className:`w-4 h-4 mx-auto mb-1 ${t.color}`}),e.jsx("p",{className:"text-xl font-bold text-foreground",children:t.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t.label})]},t.label))}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"rounded-xl border border-primary/30 bg-primary/5 p-4",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wider font-semibold text-muted-foreground",children:"Forecasted Contract Value (annual, weighted)"}),e.jsx("p",{className:"text-3xl font-extrabold text-foreground tabular-nums",children:O(R.weighted)}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Σ annual contract value × close probability across open deals."})]}),e.jsxs("div",{className:"rounded-xl border border-border bg-card p-4",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wider font-semibold text-muted-foreground",children:"Open Pipeline (annual, gross)"}),e.jsx("p",{className:"text-3xl font-extrabold text-foreground tabular-nums",children:O(R.gross)}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Total annualised value of all open quotes before probability weighting."})]})]}),_.length>0&&e.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-xl p-5",children:[e.jsxs("h2",{className:"font-bold text-red-800 flex items-center gap-2 mb-3",children:[e.jsx(te,{className:"w-5 h-5"})," Needs Action — ",_.length," ",_.length===1?"item requires":"items require"," attention"]}),e.jsx("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:_.map((t,n)=>e.jsxs("div",{className:"bg-white rounded-lg border border-red-100 p-3 flex flex-col sm:flex-row sm:items-center gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${M[t.priority]}`,children:t.priority}),e.jsx("p",{className:"font-bold text-foreground truncate text-sm",children:t.record.company_name})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[t.reason," — ",t.action]})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[t.action.includes("inspection")&&e.jsxs(d,{size:"sm",variant:"default",onClick:()=>s(`/staff/inspection?id=${t.record.id}`),children:[e.jsx(Y,{className:"w-3 h-3 mr-1"})," Inspect"]}),e.jsxs(d,{size:"sm",variant:"ghost",onClick:()=>p(t.record),children:[e.jsx(q,{className:"w-3 h-3 mr-1"})," Open"]})]})]},`${t.record.id}-${n}`))})]}),w.length>0&&e.jsxs("div",{className:"bg-orange-50 border border-orange-200 rounded-xl p-5",children:[e.jsxs("h2",{className:"font-bold text-orange-800 flex items-center gap-2 mb-3",children:[e.jsx(W,{className:"w-5 h-5"})," Follow-Up Today — ",w.length," ",w.length===1?"quote needs":"quotes need"," follow-up"]}),e.jsx("div",{className:"space-y-3",children:w.map(t=>e.jsxs("div",{className:"bg-white rounded-lg border border-orange-200 p-4 flex flex-col sm:flex-row sm:items-center gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-bold text-foreground truncate",children:t.company_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[t.contact_name," · ",t.facility_type||"Commercial"]}),e.jsxs("p",{className:"text-xs text-orange-700 mt-1",children:["Quote sent ",c(t.quote_sent_at)," · Action: Send Follow-up ",(t.follow_up_stage||0)+1]})]}),e.jsxs("div",{className:"flex gap-2 shrink-0 flex-wrap",children:[e.jsxs(d,{size:"sm",variant:"default",onClick:()=>F(t),disabled:v===t.id,children:[v===t.id?e.jsx(k,{className:"w-3 h-3 animate-spin mr-1"}):e.jsx(E,{className:"w-3 h-3 mr-1"}),"Send Follow-Up"]}),e.jsxs(d,{size:"sm",variant:"outline",onClick:()=>S(t.id,{client_replied:!0,follow_up_enabled:!1,follow_up_status:"stopped"}),children:[e.jsx(J,{className:"w-3 h-3 mr-1"})," Client Replied"]}),e.jsxs(d,{size:"sm",variant:"ghost",onClick:()=>S(t.id,{follow_up_paused:!0,follow_up_status:"Follow-up paused"}),children:[e.jsx(oe,{className:"w-3 h-3 mr-1"})," Pause"]}),e.jsxs(d,{size:"sm",variant:"ghost",onClick:()=>p(t),children:[e.jsx(q,{className:"w-3 h-3 mr-1"})," Open"]})]})]},t.id))})]}),w.length===0&&_.length===0&&!u&&e.jsx("div",{className:"bg-green-50 border border-green-200 rounded-xl p-4 text-center text-green-800 text-sm",children:"✓ No follow-ups or actions required today."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsx(se,{placeholder:"Search company or c
5ontact…",value:L,onChange:t=>j(t.target.value),className:"sm:max-w-xs"}),e.jsxs(H,{value:f,onValueChange:z,children:[e.jsx(B,{className:"sm:w-48",children:e.jsx(V,{})}),e.jsxs(G,{children:[e.jsx(C,{value:"all",children:"All Stages"}),re.map(t=>e.jsx(C,{value:t.key,children:t.label},t.key))]})]}),e.jsxs(d,{variant:"outline",size:"sm",onClick:g,disabled:u,children:[e.jsx(ie,{className:`w-4 h-4 mr-1 ${u?"animate-spin":""}`})," Refresh"]})]}),u?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(k,{className:"w-8 h-8 animate-spin text-primary"})}):T.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:["No pipeline records found. Create quotes from the ",e.jsx("button",{onClick:()=>s("/staff/quote"),className:"text-primary underline",children:"Quote Tool"}),"."]}):e.jsx("div",{className:"bg-card rounded-xl border border-border 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 bg-muted/50",children:[e.jsx("th",{className:"text-left px-4 py-3 font-semibold",children:"Company"}),e.jsx("th",{className:"text-left px-4 py-3 font-semibold hidden md:table-cell",children:"Contact"}),e.jsx("th",{className:"text-left px-4 py-3 font-semibold hidden lg:table-cell",children:"Facility"}),e.jsx("th",{className:"text-left px-4 py-3 font-semibold",children:"Status"}),e.jsx("th",{className:"text-left px-4 py-3 font-semibold hidden md:table-cell",children:"Follow-Up"}),e.jsx("th",{className:"text-left px-4 py-3 font-semibold hidden lg:table-cell",children:"Price"}),e.jsx("th",{className:"text-left px-4 py-3 font-semibold",children:"Date"}),e.jsx("th",{className:"px-4 py-3"})]})}),e.jsx("tbody",{children:T.map(t=>e.jsxs("tr",{className:"border-b border-border hover:bg-muted/20 transition-colors cursor-pointer",onClick:()=>p(t),children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:t.company_name}),(()=>{const n=K(t);return n.label.includes("COLD")?null:e.jsx("span",{className:`inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-bold ${n.color}`,children:n.label})})(),(()=>{const n=X(t);return e.jsxs("span",{className:`inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-bold border ${ce(n)}`,title:"Close probability",children:[n,"%"]})})()]})}),e.jsx("td",{className:"px-4 py-3 hidden md:table-cell text-muted-foreground",children:t.contact_name}),e.jsx("td",{className:"px-4 py-3 hidden lg:table-cell text-muted-foreground",children:t.facility_type||"—"}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${U[t.status]||U.Lead}`,children:t.status})}),e.jsx("td",{className:"px-4 py-3 hidden md:table-cell text-xs text-muted-foreground",children:(()=>{const n=de(t);return n?e.jsx("span",{className:`font-semibold ${n.color}`,children:n.label}):t.follow_up_status||"—"})()}),e.jsxs("td",{className:"px-4 py-3 hidden lg:table-cell text-muted-foreground",children:[t.estimated_price_low?`$${Number(t.estimated_price_low).toLocaleString()}`:"—",t.estimated_price_high?` – $${Number(t.estimated_price_high).toLocaleString()}`:""]}),e.jsx("td",{className:"px-4 py-3 text-muted-foreground text-xs",children:l(t.created_at)}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(d,{variant:"ghost",size:"sm",onClick:n=>{n.stopPropagation(),p(t)},children:e.jsx(q,{className:"w-4 h-4"})})})]},t.id))})]})})]})]}),e.jsx(he,{open:!!r,onOpenChange:t=>!t&&p(null),children:e.jsxs(fe,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(ge,{children:e.jsx(be,{children:r==null?void 0:r.company_name})}),r&&e.jsx(Te,{record:r,actionLoading:v,onUpdate:t=>S(r.id,t),onSendFollowUp:()=>F(r),onRefresh:g,onNavigateInspection:()=>s(`/staff/inspection?id=${r.id}`)})]})})]})},Te=({record:s,actionLoading:o,onUpdate:i,onSendFollowUp:u,onRefresh:a,onNavigateInspection:r})=>{const[p,f]=x.useState(s.notes||""),[z,L]=x.useState(s.lost_reason||""),[j,v]=x.useState(!1),[y,g]=x.use
5State(!1),[$,w]=x.useState(!1),[_,T]=x.useState(null),b=o===s.id,A=K(s),h=de(s),m=s.email_delivery_status||"pending",N=m==="failed",D=l=>l?new Date(l).toLocaleString("en-AU",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):"—",I=async(l,c)=>{v(!0);try{await P.functions.invoke("resend-proposal-email",{body:{pipelineId:s.id,resendClient:l,resendAdmin:c}}),ee({action:"proposal_resent",entityType:"sales_pipeline",entityId:s.id,metadata:{resendClient:l,resendAdmin:c,company:s.company_name}}),a()}catch(M){console.error("Resend error:",M)}finally{v(!1)}},R=(l,c)=>{navigator.clipboard.writeText(l),T(c),setTimeout(()=>T(null),2e3)},O=[["Contact",s.contact_name],["Email",s.email],["Phone",s.phone],["Facility",s.facility_type],["Address",s.address],["Frequency",s.cleaning_frequency],["Price",s.estimated_price_low?`$${Number(s.estimated_price_low).toLocaleString()}${s.estimated_price_high?` – $${Number(s.estimated_price_high).toLocaleString()}`:""}`:"—"],["Quote Sent",s.quote_sent_at?new Date(s.quote_sent_at).toLocaleDateString("en-AU"):"—"],["Follow-Up Status",s.follow_up_status||"None"],["Follow-Up Stage",s.follow_up_stage?`${s.follow_up_stage}/3`:"0/3"],["Client Replied",s.client_replied?"Yes":"No"]],S=[{label:"Facility type confirmed",met:!!s.facility_type},{label:"Address / suburb provided",met:!!s.address},{label:"Cleaning frequency set",met:!!s.cleaning_frequency},{label:"Price estimate provided",met:!!(s.estimated_price_low||s.estimated_price_high)}],F=S.every(l=>l.met);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${U[s.status]||U.Lead}`,children:s.status}),e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded text-xs font-bold ${A.color}`,children:A.label}),(()=>{const l=X(s);return e.jsxs("span",{className:`inline-flex items-center px-2 py-0.5 rounded text-xs font-bold border ${ce(l)}`,title:"Close probability",children:[l,"% close probability"]})})(),h&&e.jsxs("span",{className:`text-xs font-semibold ${h.color}`,children:["⏱ ",h.label," ",h.minutes>=120?"— OVERDUE":h.minutes>=30?"— RESPOND NOW":""]})]}),A.label==="🔥 HOT"&&e.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-3 text-sm text-red-800 font-medium flex items-center gap-2",children:[e.jsx(W,{className:"w-4 h-4 shrink-0"}),"HIGH VALUE LEAD — Priority response required. Target callback within 15 minutes."]}),e.jsx("div",{className:"grid grid-cols-2 gap-2 text-sm",children:O.map(([l,c])=>e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:l}),e.jsx("span",{className:"font-medium truncate",children:c||"—"})]},l))}),e.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-2",children:[e.jsxs("p",{className:"text-xs font-semibold text-muted-foreground uppercase flex items-center gap-1",children:[e.jsx(Y,{className:"w-3 h-3"})," Qualification Checklist"]}),e.jsx("div",{className:"grid grid-cols-2 gap-1",children:S.map(l=>e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[l.met?e.jsx(ae,{className:"w-3 h-3 text-green-600 shrink-0"}):e.jsx(ne,{className:"w-3 h-3 text-red-400 shrink-0"}),e.jsx("span",{className:l.met?"text-foreground":"text-muted-foreground",children:l.label})]},l.label))}),!F&&s.status==="Lead"&&e.jsx("p",{className:"text-xs text-yellow-700 bg-yellow-50 rounded p-1.5 mt-1",children:"⚠ Complete qualification before moving to Quote Sent"})]}),e.jsxs("div",{className:"rounded-lg border border-border overflow-hidden",children:[e.jsxs("button",{onClick:()=>g(!y),className:"w-full flex items-center justify-between p-3 text-xs font-semibold text-muted-foreground uppercase hover:bg-muted/30 transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(le,{className:"w-3 h-3"})," Call Script"]}),e.jsx("span",{children:y?"▲":"▼"})]}),y&&e.jsx("div",{className:"p-3 pt-0 space-y-3 border-t border-border",children:Le.map((l,c)=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-bold text-foreground",children:l.title}),e.jsx("p",{className:"text-xs text-muted-foreground whitespace-pre-line bg-muted/30 rounded p-2",children:l.content})]}
5,c))})]}),e.jsxs("div",{className:"rounded-lg border border-border overflow-hidden",children:[e.jsxs("button",{onClick:()=>w(!$),className:"w-full flex items-center justify-between p-3 text-xs font-semibold text-muted-foreground uppercase hover:bg-muted/30 transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(J,{className:"w-3 h-3"})," Objection Responses"]}),e.jsx("span",{children:$?"▲":"▼"})]}),$&&e.jsx("div",{className:"p-3 pt-0 space-y-2 border-t border-border",children:ke.map((l,c)=>e.jsxs("div",{className:"flex items-start gap-2 bg-muted/30 rounded p-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-bold text-foreground mb-0.5",children:l.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l.response})]}),e.jsx(d,{size:"sm",variant:"ghost",className:"shrink-0 text-xs h-7",onClick:()=>R(l.response,c),children:_===c?"✓ Copied":"Copy"})]},c))})]}),e.jsxs("div",{className:`rounded-lg border p-3 space-y-2 ${N?"bg-destructive/5 border-destructive/30":"bg-muted/30 border-border"}`,children:[e.jsxs("p",{className:"text-xs font-semibold text-muted-foreground uppercase flex items-center gap-1",children:[N&&e.jsx(W,{className:"w-3 h-3 text-destructive"}),"Email Delivery"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Status"}),e.jsx("span",{className:`font-medium ${N?"text-destructive":m==="delivered"?"text-primary":"text-muted-foreground"}`,children:m==="delivered"?"✓ Delivered":N?"✗ Failed":m==="no_email"?"No email":"Pending"})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Client Sent At"}),e.jsx("span",{className:"font-medium",children:D(s.client_email_sent_at)})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Admin Sent At"}),e.jsx("span",{className:"font-medium",children:D(s.admin_email_sent_at)})]}),s.client_email_error&&e.jsxs("div",{className:"flex flex-col col-span-2",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Client Error"}),e.jsx("span",{className:"font-medium text-destructive text-xs break-all",children:s.client_email_error})]}),s.admin_email_error&&e.jsxs("div",{className:"flex flex-col col-span-2",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Admin Error"}),e.jsx("span",{className:"font-medium text-destructive text-xs break-all",children:s.admin_email_error})]})]}),(N||m==="pending")&&s.proposal_pdf_path&&e.jsxs("div",{className:"flex flex-wrap gap-2 pt-2 border-t border-border",children:[e.jsxs(d,{size:"sm",variant:"destructive",onClick:()=>I(!0,!1),disabled:j||!s.email,children:[j?e.jsx(k,{className:"w-3 h-3 animate-spin mr-1"}):e.jsx(ie,{className:"w-3 h-3 mr-1"}),"Resend Client Email"]}),e.jsxs(d,{size:"sm",variant:"outline",onClick:()=>I(!1,!0),disabled:j,children:[j?e.jsx(k,{className:"w-3 h-3 animate-spin mr-1"}):e.jsx(E,{className:"w-3 h-3 mr-1"}),"Resend ACC Internal"]}),e.jsxs(d,{size:"sm",variant:"outline",onClick:()=>I(!0,!0),disabled:j||!s.email,children:[j?e.jsx(k,{className:"w-3 h-3 animate-spin mr-1"}):e.jsx(E,{className:"w-3 h-3 mr-1"}),"Resend Both"]})]})]}),e.jsx("div",{children:e.jsxs(d,{size:"sm",variant:"outline",className:"w-full",onClick:r,children:[e.jsx(Y,{className:"w-4 h-4 mr-2"})," Generate Proposal from Inspection Notes"]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase",children:"Move to Stage"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:re.map(l=>e.jsx(d,{size:"sm",variant:s.status===l.key?"default":"outline",disabled:s.status===l.key||b,onClick:()=>{const c={status:l.key};(l.key==="Contract Won"||l.key==="Contract Lost")&&(c.follow_up_enabled=!1,c.follow_up_status="stopped",ee({action:l.key==="Contract Won"?"deal_won":"deal_lost",entityType:"sales_pipeline",entityId:s.id,metadata:{company:s.company_name,contract_value:s.contract_value}})),l.key==="Inspection Scheduled"&&(c.follow_up_enabled=!1,c.follow_up_status="stopped",c.inspection_booked_at=new Date().toISOString()),i(c)},className:"text-xs",children:l.label},l.key))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase",children:"Follow-Up Controls"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(d,{size:"sm",variant:"default",onClick:u,disabled:b||!s.email||s.follow_up_stage>=3,children:[b?e.jsx(k,{className:"w-3 h-3 animate-spin mr-1"}):e.jsx(E,{className:"w-3 h-3 mr-1"}),"Send Follow-Up ",Math.min((s.follow_up_stage||0)+1,3)]}),e.jsxs(d,{size:"sm",variant:"outline",onClick:()=>i({client_replied:!0,follow_up_enabled:!1,follow_up_status:"stopped"}),disabled:b,children:[e.jsx(J,{className:"w-3 h-3 mr-1"})," Client Replied"]}),s.follow_up_paused?e.jsxs(d,{size:"sm",variant:"outline",onClick:()=>i({follow_up_paused:!1,follow_up_status:`Follow-up ${s.follow_up_stage} sent`}),disabled:b,children:[e.jsx(Ne,{className:"w-3 h-3 mr-1"})," Resume"]}):e.jsxs(d,{size:"sm",variant:"outline",onClick:()=>i({follow_up_paused:!0,follow_up_status:"Follow-up paused"}),disabled:b,children:[e.jsx(oe,{className:"w-3 h-3 mr-1"})," Pause"]})]})]}),s.status==="Contract Won"&&e.jsxs("div",{className:"bg-green-50 border border-green-200 rounded-lg p-3 space-y-2",children:[e.jsx("p",{className:"text-xs font-semibold text-green-800 uppercase",children:"🎉 Contract Won Details"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Contract Value"}),e.jsx("span",{className:"font-bold text-foreground",children:s.contract_value?`$${Number(s.contract_value).toLocaleStr
5ing()}/mo`:"—"})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Service Type"}),e.jsx("span",{className:"font-medium",children:s.facility_type||"—"})]})]}),!s.contract_value&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(se,{type:"number",placeholder:"Monthly value ($)",className:"text-sm max-w-[160px]",id:"contract-value-input"}),e.jsx(d,{size:"sm",onClick:()=>{const l=document.getElementById("contract-value-input");l!=null&&l.value&&i({contract_value:Number(l.value)})},children:"Save Value"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs block mb-1",children:"Selected Tier"}),e.jsxs(H,{onValueChange:l=>i({selected_tier:l}),children:[e.jsx(B,{className:"text-sm max-w-[180px]",children:e.jsx(V,{placeholder:"Which tier won?"})}),e.jsxs(G,{children:[e.jsx(C,{value:"essential",children:"Essential"}),e.jsx(C,{value:"standard",children:"Standard"}),e.jsx(C,{value:"premium",children:"Premium"})]})]})]})]})]}),s.status==="Contract Lost"&&e.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-3 space-y-2",children:[e.jsx("p",{className:"text-xs font-semibold text-red-800 uppercase",children:"Loss Analysis"}),e.jsxs(H,{value:z,onValueChange:l=>{L(l),i({lost_reason:l})},children:[e.jsx(B,{className:"text-sm",children:e.jsx(V,{placeholder:"Select loss reason…"})}),e.jsx(G,{children:Ce.map(l=>e.jsx(C,{value:l,children:l},l))})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase mb-1",children:"Notes"}),e.jsx(je,{value:p,onChange:l=>f(l.target.value),rows:3,className:"text-sm"}),e.jsx(d,{size:"sm",className:"mt-2",onClick:()=>i({notes:p}),children:"Save Notes"})]})]})};export{ze 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.