1import{bg as s,F as a,W as e,ar as l,bw as i}from"./B7N87Dgv.js";import{f as t,g as r}from"./H3wU2S2t.js";import{g as c,a as d}from"./D8WwgRBT.js";import{ef as n,a1 as o,h as m,i as h,j as u,k as v,l as f,B as p,a2 as x}from"./C8tXTfP_.js";import{T as g,a as j,b as y,c as b}from"./DKqV88rE.js";import"./IcBk4aGI.js";import"./wXrpDM_j.js";function _(){var _,N;const P=s({from:n.fullPath}),{tab:S,...D}=n.useSearch(),{companyId:k}=n.useParams(),{data:w,isPending:C}=t({...D,defect_status:"defects"===S?"open":void 0}),I=c(),R=a.useMemo(()=>{var s;return((null==(s=null==w?void 0:w.data)?void 0:s.items)??[]).map(s=>r(s))},[null==(_=null==w?void 0:w.data)?void 0:_.items]),V=a.useMemo(()=>{var s;return((null==(s=null==w?void 0:w.data)?void 0:s.items)??[]).map(s=>({...s,inspection_time:s.inspection_time??void 0,safety_status:s.safety_status??void 0,type:s.type??void 0}))},[null==(N=null==w?void 0:w.data)?void 0:N.items]),B=s=>{P({to:".",search:a=>({...a,...s,page:1})})},L=Boolean(D.search||D.defect_search||"all"!==D.safety_status);return e.jsx("div",{className:"space-y-4",children:e.jsxs(g,{value:S,onValueChange:s=>P({to:".",search:a=>({...a,tab:s})}),children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(j,{children:[e.jsx(y,{value:"defects",children:"Defects"}),e.jsx(y,{value:"dvirs",children:"DVIRs"})]}),e.jsxs("div",{className:"flex w-fit items-center gap-2",children:[e.jsx("div",{className:"grid flex-1 shrink-0 basis-45 gap-2 sm:flex-0 sm:basis-64",children:e.jsx(o,{value:D.search,onChange:s=>B({search:s}
1),placeholder:"Search by vehicle"})}),e.jsx("div",{className:"grid flex-1 shrink-0 basis-45 gap-2 sm:flex-0 sm:basis-64",children:e.jsx(o,{value:D.defect_search,onChange:s=>B({defect_search:s}),placeholder:"Search defect"})}),"dvirs"===S&&e.jsx("div",{className:"grid flex-1 shrink-0 basis-45 gap-2 sm:flex-0 sm:basis-64",children:e.jsxs(m,{value:D.safety_status,onValueChange:s=>B({safety_status:s}),children:[e.jsx(h,{className:"w-full",children:e.jsx(u,{placeholder:"DVIR Status"})}),e.jsxs(v,{children:[e.jsx(f,{value:"all",children:"DVIR Status"}),e.jsx(f,{value:"safe",children:"Safe to Drive"}),e.jsx(f,{value:"unsafe",children:"Unsafe to Drive"}),e.jsx(f,{value:"resolved",children:"Resolved"})]})]})}),L&&e.jsxs(p,{variant:"ghost",className:"px-2 lg:px-3",onClick:()=>{P({to:".",search:s=>({...s,page:1,search:"",defect_search:"",safety_status:"all"})})},children:["Reset",e.jsx(l,{icon:i})]})]})]}),e.jsx(b,{value:"defects",className:"space-y-4",children:e.jsx(x,{className:"w-table",data:R,columns:d({companyId:k}),isLoading:C,page:D.page,limit:D.limit,totalPages:(null==w?void 0:w.data.paging.totalPages)??1,showPageSizeOptions:!1})}),e.jsx(b,{value:"dvirs",className:"space-y-4",children:e.jsx(x,{data:V,columns:I,isLoading:C,page:D.page,limit:D.limit,totalPages:(null==w?void 0:w.data.paging.totalPages)??1})})]})})}export{_ as component};
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.