PageSourceSearch

https://app.limohive.com/assets/index-DF4PzdKi.js

js limohive.com collected 2026-10-05 20:35:42 UTC 12,918 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-dnd-5UzT-EHT.js";import{P as C}from"./index-DOvcJ8G9.js";import{h as G}from"./vendor-charts-CJg5fMnl.js";import{r as l}from"./vendor-react-Ds1CvfpE.js";import{M as J}from"./index-B0Bps5lg.js";import{B as g}from"./Button-LQFze9v9.js";import{L as d}from"./Label-Cz9L-Zqz.js";import{I as S}from"./InputField-CHPZIFY8.js";import{a as p}from"./vendor-http-C0Zqfgkc.js";import"./vendor-utils-B7IwALc3.js";const F=["#ef4444","#f97316","#f59e0b","#eab308","#84cc16","#22c55e","#14b8a6","#06b6d4","#3b82f6","#8b5cf6","#a855f7","#ec4899","#f43f5e","#6366f1"],R=[{value:"hourly",label:"Hourly"},{value:"transfer",label:"Transfer"},{value:"roundtrip",label:"Roundtrip"}];function oe(){const[L,m]=l.useState(!1),[i,A]=l.useState([]),[D,y]=l.useState(!0),[f,z]=l.useState([]),[v,M]=l.useState([]),[b,B]=l.useState([]),[j,k]=l.useState([]),[O,$]=l.useState([]),[a,h]=l.useState({timeline:"YTD",dateFrom:"",dateTo:"",tripType:"",vendorId:"",salesRepId:"",company:"",categoryId:"",subcategoryId:""}),[r,n]=l.useState(a);l.useEffect(()=>{const s={Authorization:`Bearer ${localStorage.getItem("token")}`};Promise.all([p.get("/api/vendors?status=Active",{headers:s}),p.get("/api/users-salesreps",{headers:s}),p.get("/api/leads/companies",{headers:s}),p.get("/api/categories",{headers:s})]).then(([o,H,_,q])=>{z(o.data),M(H.data),$(_.data),B(q.data)}).catch(console.error)},[]),l.useEffect(()=>{if(r.categoryId){const t=localStorage.getItem("token");p.get(`/api/categories/${r.categoryId}/subcategories`,{headers:{Authorization:`Bearer ${t}`}}).then(s=>k(s.data)).catch(console.error)}else k([])},[r.categoryId]);const I=l.useCallback(()=>{const t=new URLSearchParams;return t.append("timeline",a.timeline),a.timeline==="Custom"&&(a.dateFrom&&t.append("dateFrom",a.dateFrom),a.dateTo&&t.append("dateTo",a.dateTo)),a.tripType&&t.append("tripType",a.tripType),a.vendorId&&t.append("vendorId",a.vendorId),a.salesRepId&&t.append("salesRepId",a.salesRepId),a.company&&t.append("company",a.company),a.categoryId&&t.append("categoryId",a.categoryId),a.subcategoryId&&t.append("subcategoryId",a.subcategoryId),t.toString()},[a]),N=l.useCallback(async()=>{try{y(!0);const t=localStorage.getItem("token"),s=await p.get(`/api/dashboard/lost-reason-stats?${I()}`,{headers:{Authorization:`Bearer ${t}`}});A(s.data)}catch(t){console.error("Error fetching lost reason stats:",t)}finally{y(!1)}},[I]);l.useEffect(()=>{N()},[N]);const Y=()=>{h(r),m(!1)},E=()=>{const t={timeline:"YTD",dateFrom:"",dateTo:"",tripType:"",vendorId:"",salesRepId:"",company:"",categoryId:"",subcategoryId:""};n(t),h(t),m(!1)},x=l.useMemo(()=>i.reduce((t,s)=>t+s.count,0),[i]),u=l.useMemo(()=>i.map((t,s)=>F[s%F.length]),[i]),W=l.useMemo(()=>({colors:u,labels:i.map(t=>t.reason),chart:{fontFamily:"Outfit, sans-serif",type:"donut",height:350},plotOptions:{pie:{donut:{size:"65%",background:"transparent",labels:{show:!0,name:{show:!0,fontSize:"14px",fontWeight:600},value:{show:!0,fontSize:"22px",fontWeight:700},total:{show:!0,label:"Total Lost",fontSize:"12px",fontWeight:400,formatter:()=>x.toString()}}}}},dataLabels:{enabled:!1},tooltip:{enabled:!0,y:{formatter:t=>`${t} leads`}},stroke:{show:!1,width:4},legend:{show:!0,position:"bottom",horizontalAlign:"center",fontFamily:"Outfit",fontSize:"13px",fontWeight:400,markers:{size:5,shape:"circle",strokeWidth:0},itemMargin:{horizontal:10,vertical:5}},responsive:[{breakpoint:640,options:{chart:{height:300}}}]}),[i,x,u]),w=a.tripType||a.vendorId||a.salesRepId||a.company||a.categoryId||a.subcategoryId||a.timeline!=="YTD",V=()=>{const t=[];if(a.timeline!=="YTD"&&(a.timeline==="Custom"&&(a.dateFrom||a.dateTo)?t.push({key:"timeline",label:"Date Range",value:`${a.dateFrom||"Start"} - ${a.dateTo||"End"}`}):a.timeline==="UpToDate"&&t.push({key:"timeline",label:"Timeline",value:"Up to Date"})),a.tripType){const s=R.find(o=>o.value===a.tripType);t.push({key:"tripType",label:"Trip Type",value:s?.label||a.tripType})}if(a.vendorId){const s=f.find(o=>o.id.toString()===a.vendorId);t.push({key:"vendorId",label:"Vendor",value:s?.vendor_name||a.vendorId})}if(a.salesRepId&&t.push({key:"salesRepId",label:"Sales Rep",value:a.salesRepId==="0"?"Automation":v.find(s=>
1s.id.toString()===a.salesRepId)?.name||a.salesRepId}),a.company&&t.push({key:"company",label:"Company",value:a.company}),a.categoryId){const s=b.find(o=>o.id.toString()===a.categoryId);t.push({key:"categoryId",label:"Category",value:s?.category_name||a.categoryId})}if(a.subcategoryId){const s=j.find(o=>o.id.toString()===a.subcategoryId);t.push({key:"subcategoryId",label:"Subcategory",value:s?.subcategory_name||a.subcategoryId})}return t},P=t=>{const s={...a};t==="timeline"?(s.timeline="YTD",s.dateFrom="",s.dateTo=""):s[t]="",h(s)},U=()=>{h({timeline:"YTD",dateFrom:"",dateTo:"",tripType:"",vendorId:"",salesRepId:"",company:"",categoryId:"",subcategoryId:""})},T=V(),c="h-11 w-full rounded-lg border border-gray-300 px-4 py-2 text-sm text-gray-800 dark:border-gray-700 dark:bg-gray-800 dark:text-white focus:ring-1 focus:ring-brand-500 focus:border-brand-500";return D?e.jsxs(e.Fragment,{children:[e.jsx(C,{title:"LimoHive BackOffice | Lost Report",description:"View lost leads by reason"}),e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"text-gray-500",children:"Loading..."})})]}):e.jsxs(e.Fragment,{children:[e.jsx(C,{title:"LimoHive BackOffice | Lost Report",description:"View lost leads by reason"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-800 dark:text-white/90",children:"Lost Report"}),e.jsx(g,{size:"sm",variant:"outline",onClick:()=>{n(a),m(!0)},className:w?"border-brand-500 text-brand-500":"",children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M3 5h14M3 10h14M3 15h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),"Filter",w&&e.jsx("span",{className:"w-2 h-2 rounded-full bg-brand-500"})]})})]}),T.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Active filters:"}),T.map(t=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-xs bg-brand-50 text-brand-700 dark:bg-brand-900/30 dark:text-brand-300",children:[e.jsxs("span",{className:"font-medium",children:[t.label,":"]})," ",t.value,e.jsx("button",{onClick:()=>P(t.key),className:"ml-0.5 hover:text-brand-900 dark:hover:text-brand-100",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",children:e.jsx("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]},t.key)),e.jsx("button",{onClick:U,className:"text-xs text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 underline ml-1",children:"Clear all"})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-white p-4 dark:border-gray-800 dark:bg-white/[0.03]",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-800 dark:text-white/90",children:"Lost Reasons"}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:["Total Lost: ",e.jsx("span",{className:"font-semibold text-gray-800 dark:text-white",children:x})]})]}),e.jsx("div",{className:"flex justify-center",children:i.length>0?e.jsx(G,{options:W,series:i.map(t=>t.count),type:"donut",height:320}):e.jsx("div",{className:"flex h-[320px] items-center justify-center text-gray-400 text-sm",children:"No lost reason data available"})})]}),e.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-white p-4 dark:border-gray-800 dark:bg-white/[0.03]",children:[e.jsx("div",{className:"mb-3",children:e.jsx("h3",{className:"text-base font-semibold text-gray-800 dark:text-white/90",children:"Detailed Breakdown"})}),i.length>0?e.jsx("div",{className:"space-y-2.5 max-h-[360px] overflow-y-auto pr-1",children:i.map((t,s)=>{const o=x>0?(t.count/x*100).toFixed(1):"0";return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:u[s]}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 truncate mr-2",children:t.reason}),e.jsxs("span",{className:"text-sm font-bold text-gray-800 dark:text-white flex-shrink-0",children:[t.count," ",e.jsxs("span",{className:"text-xs font-normal text-gray-400",children:["(",o,"%)"]})]})]}),e.jsx("div",{className:"w-full bg-gray-100 dark:bg-gray-700 rounded-full h-1.5",children:e.jsx("div",{className:"h-1.5 rounded-full",style:{width:`${o}%`,backgroundColor:u[s]}})})]})]},t.reason)})}):e.jsx("div",{className:"flex h-[320px] items-center justify-center text-gray-400 text-sm",children:"No data available"})]})]})]}),e.jsxs(J,{isOpen:L,onClose:()=>m(!1),className:"max-w-[700px] p-6 lg:p-10 m-4 rounded-xl bg-white dark:bg-gray-900 shadow-lg",children:[e.jsxs("div",{className:"px-2 mb-6",children:[e.jsx("h4",{className:"mb-2 text-2xl font-semibold text-gray-800 dark:text-white/90",children:"Filter Lost Report"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Filter lost leads by various criteria"})]}),e.jsxs("form",{className:"flex flex-col gap-6",onSubmit:t=>{t.preventDefault(),Y()},children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(d,{children:"Timeline"}),e.jsxs("select",{className:c,value:r.timeline,onChange:t=>n({...r,timeline:t.target.value}),children:[e.jsx("option",{value:"YTD",children:"YTD"}),e.jsx("option",{value:"UpToDate",children:"Up to Date"}),e.jsx("option",{value:"Custom",children:"Custom"})]})]}),r.timeline==="Custom"&&e.jsxs("div",{className:"sm:col-span-2 grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(d,{children:"Date From"}),e.jsx(S,{type:"date",value:r.dateFrom,onChange:t=>n({...r,dateFrom:t.target.value})})]}),e.jsxs("div",{children:[e.jsx(d,{children:"Date To"}),e.jsx(S,{type:"date",value:r.dateTo,onChange:t=>n({...r,dateTo:t.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(d,{children:"Trip Type"}
1),e.jsxs("select",{className:c,value:r.tripType,onChange:t=>n({...r,tripType:t.target.value}),children:[e.jsx("option",{value:"",children:"All Types"}),R.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))]})]}),e.jsxs("div",{children:[e.jsx(d,{children:"Vendor"}),e.jsxs("select",{className:c,value:r.vendorId,onChange:t=>n({...r,vendorId:t.target.value}),children:[e.jsx("option",{value:"",children:"All Vendors"}),f.map(t=>e.jsx("option",{value:t.id,children:t.vendor_name},t.id))]})]}),e.jsxs("div",{children:[e.jsx(d,{children:"Sales Rep"}),e.jsxs("select",{className:c,value:r.salesRepId,onChange:t=>n({...r,salesRepId:t.target.value}),children:[e.jsx("option",{value:"",children:"All Sales Reps"}),e.jsx("option",{value:"0",children:"Automation"}),v.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]})]}),e.jsxs("div",{children:[e.jsx(d,{children:"Company"}),e.jsxs("select",{className:c,value:r.company,onChange:t=>n({...r,company:t.target.value}),children:[e.jsx("option",{value:"",children:"All Companies"}),O.map(t=>e.jsx("option",{value:t,children:t},t))]})]}),e.jsxs("div",{children:[e.jsx(d,{children:"Category"}),e.jsxs("select",{className:c,value:r.categoryId,onChange:t=>n({...r,categoryId:t.target.value,subcategoryId:""}),children:[e.jsx("option",{value:"",children:"All Categories"}),b.map(t=>e.jsx("option",{value:t.id,children:t.category_name},t.id))]})]}),e.jsxs("div",{children:[e.jsx(d,{children:"Subcategory"}),e.jsxs("select",{className:c,value:r.subcategoryId,onChange:t=>n({...r,subcategoryId:t.target.value}),disabled:!r.categoryId,children:[e.jsx("option",{value:"",children:"All Subcategories"}),j.map(t=>e.jsx("option",{value:t.id,children:t.subcategory_name},t.id))]})]})]}),e.jsxs("div",{className:"flex flex-col-reverse items-center justify-between gap-3 sm:flex-row",children:[e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[e.jsx(g,{type:"button",variant:"outline",size:"md",onClick:()=>m(!1),className:"flex-1 sm:flex-none",children:"Cancel"}),e.jsx(g,{type:"button",variant:"outline",size:"md",onClick:E,className:"flex-1 sm:flex-none",children:"Reset"})]}),e.jsx(g,{type:"submit",size:"md",className:"w-full sm:w-auto bg-brand-500 hover:bg-brand-600 text-white",children:"Apply Filters"})]})]})]})]})}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.