1import{u,F as j,C as v,D as N,S as y,j as e,a as i,b as r,T as b,c as f,B as t,d as g}from"./index-_mKUVpXQ.js";import{m as _,d as C,a as k}from"./format-BmJsg3OJ.js";import{P as c}from"./plus-ZJ99q1IL.js";function q({setTab:l}){var d,m,x,o;const{data:s,isLoading:n}=u({queryKey:["dashboard"],queryFn:()=>g.get("/api/dashboard")}),h=[{label:"Active rentals",value:s==null?void 0:s.active_rentals,icon:j,tab:"rentals"},{label:"Cars available",value:s==null?void 0:s.cars_available,icon:v,tab:"vehicles"},{label:"Payments due",value:_((d=s==null?void 0:s.payments_due)==null?void 0:d.amount),sub:`${((m=s==null?void 0:s.payments_due)==null?void 0:m.count)||0} items`,icon:N,tab:"payments"},{label:"Compliance due",value:s==null?void 0:s.compliance_due,icon:y,tab:"compliance"}];return e.jsxs("div",{className:"space-y-6 max-w-6xl",children:[e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 sm:gap-4",children:h.map(a=>e.jsxs(i,{className:"p-4 cursor-pointer hover:border-primary/40 transition",onClick:()=>l(a.tab),children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm text-muted",children:a.label}),e.jsx(a.icon,{size:18,className:"text-primary"})]}),n?e.jsx(r,{className:"h-7 w-16"}):e.jsx("div",{className:"text-2xl font-display font-bold tnum",children:a.value??0}),a.sub&&e.jsx("div",{className:"text-xs text-muted mt-0.5",children:a.sub})]},a.label))}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-6",children:[e.jsxs(i,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(b,{size:18,className:"text-warn"}),e.jsx("h2",{className:"font-display font-bold",children:"Action required today"})]}),n?e.jsx(r,{className:"h-20"}):(x=s==null?void 0:s.action_required)!=null&&x.length?e.jsx("div",{className:"space-y-2",children:s.action_required.map(a=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-xl bg-bg",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium text-sm",children:[a.full_name," · ",a.plate]}),e.jsxs("div",{className:"text-xs text-muted",children:["Rental ",a.rental_code," due ",C(a.end_date)]})]}),e.jsx(f,{value:"Overdue"})]},a.rental_code))}):e.jsx("p",{className:"text-sm text-muted py-6 text-center",children:"Nothing needs attention. Nice."})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(i,{className:"p-5",children:[e.jsx("h2",{className:"font-display font-bold mb-4",children:"Quick actions"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs(t,{variant:"soft",onClick:()=>l("rentals"),children:[e.jsx(c,{size:16})," New rental"]}),e.jsxs(t,{variant:"soft",onClick:()=>l("drivers"),children:[e.jsx(c,{size:16})," Add driver"]}),e.jsxs(t,{variant:"soft",onClick:()=>l("vehicles"),children:[e.jsx(c,{size:16})," Add vehicle"]}),e.jsxs(t,{variant:"soft",onClick:()=>l("payments"),children:[e.jsx(c,{size:16})," Add payment"]})]})]}),e.jsxs(i,{className:"p-5",children:[e.jsx("h2",{className:"font-display font-bold mb-4",children:"Recent activity"}),n?e.jsx(r,{className:"h-20"}):e.jsxs("div",{className:"space-y-2.5",children:[((s==null?void 0:s.recent_activity)||[]).slice(0,8).map((a,p)=>e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[e.jsx("span",{className:"w-1.5 h-1.5 mt-1.5 rounded-full bg-primary shrink-0"}),e.jsx("span",{className:"flex-1",children:a.summary}),e.jsx("span",{className:"text-xs text-muted whitespace-nowrap",children:k(a.created_at)})]},p)),!((o=s==null?void 0:s.recent_activity)!=null&&o.length)&&e.jsx("p",{className:"text-sm text-muted",children:"No activity yet."})]})]})]})]})]})}export{q 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.