1import{r as D}from"./rolldown-runtime-b3L32Ng1.js";import{f as E,g as B,i as b,m as I}from"./vendor-react-B4z8l9H_.js";import{j as q}from"./avatar-HhL1kVi8.js";import{Dn as A,Qi as F,Ti as U,ei as $,hi as z,ii as j,ki as M,kr as Q,s as W,sa as G}from"./lucideRegistry-QWKS7J2W.js";import{t as p}from"./button-CsktFLsW.js";import{a as o,i,n as c,t as n}from"./card-BtenG7My.js";import{t as d}from"./badge-D-6zwUSe.js";import{t as J}from"./rentalReservationsService-trUpuyn2.js";import{r as K}from"./rentalVehiclesService-BzH_8hFx.js";import{r as O}from"./rentalBlocksService-B3gWeL14.js";var m=D(B()),e=I();function de(){const{t:s,i18n:N}=G("apps"),h=q(N.resolvedLanguage),{siteId:r}=E(),[v,f]=(0,m.useState)(!0),[g,w]=(0,m.useState)([]),[l,y]=(0,m.useState)({pendingTotal:0,confirmedToday:0,revenueToday:0,blockedVehicles:0});(0,m.useEffect)(()=>{r&&k()},[r]);async function k(){try{f(!0);const[t,T,_]=await Promise.all([J(r),K(r),O(r)]),x=new Date().toLocaleDateString("en-CA"),u=t.filter(a=>a.pickup_date===x),R=t.filter(a=>a.status==="pending").length,S=u.filter(a=>a.status==="confirmed").length,V=u.filter(a=>a.status==="confirmed"||a.status==="completed").reduce((a,P)=>a+Number(P.total_price||0),0),H=new Set(_.filter(a=>a.start_date<=x&&a.end_date>=x).map(a=>a.vehicle_id)),L=T.filter(a=>H.has(a.id)).length;w(u),y({pendingTotal:R,confirmedToday:S,revenueToday:V,blockedVehicles:L})}catch(t){console.error("Errore caricamento dashboard rentals:",t)}finally{f(!1)}}function C(t){return t==="pending"?(0,e.jsx)(d,{variant:"outline",className:"bg-amber-500/10 text-amber-600 border-amber-500/20 font-bold",children:s("rentals.status.pending")}):t==="confirmed"?(0,e.jsx)(d,{variant:"outline",className:"bg-[#2fb380]/10 text-[#2fb380] border-[#2fb380]/20 font-bold",children:s("rentals.status.confirmed")}):t==="completed"?(0,e.jsx)(d,{variant:"outline",className:"bg-slate-500/10 text-slate-500 border-slate-500/20 font-bold",children:s("rentals.status.completed")}):t==="cancelled"?(0,e.jsx)(d,{variant:"outline",className:"text-muted-foreground font-bold",children:s("rentals.status.cancelled")}):(0,e.jsx)(d,{variant:"outline",children:t})}return v?(0,e.jsx)("div",{className:"flex h-[50vh] items-center justify-center",children:(0,e.jsx)(A,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,e.jsxs)("div",{className:"p-6 md:p-8 max-w-7xl mx-auto animate-in fade-in duration-500 space-y-8",children:[(0,e.jsxs)("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h2",{className:"text-2xl font-semibold tracking-tight text-foreground",children:s("rentals.dashboard.title")}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:s("rentals.dashboard.subtitle")})]}),(0,e.jsx)("div",{className:"flex items-center gap-2",children:l.pendingTotal>0&&(0,e.jsx)(p,{asChild:!0,className:"bg-blue-600 hover:bg-blue-700 text-white gap-2 font-semibold shadow-sm",children:(0,e.jsxs)(b,{to:`/sites/${r}/rentals/reservations`,children:[(0,e.jsx)(j,{className:"h-4 w-4"}),s("rentals.dashboard.manageRequests",{count:l.pendingTotal})]})})})]}),(0,e.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-4",children:[(0,e.jsxs)(n,{className:"shadow-sm",children:[(0,e.jsxs)(i,{className:"flex flex-row items-center justify-between pb-2",children:[(0,e.jsx)(o,{className:"text-sm font-medium text-muted-foreground",children:s("rentals.dashboard.toConfirm")}),(0,e.jsx)(j,{className:"h-4 w-4 text-amber-500"})]}),(0,e.jsxs)(c,{children:[(0,e.jsx)("div",{className:"text-3xl font-bold text-foreground",children:l.pendingTotal}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:s("rentals.dashboard.toConfirmHint")})]})]}),(0,e.jsxs)(n,{className:"shadow-sm",children:[(0,e.jsxs)(i,{className:"flex flex-row items-center justify-between pb-2",children:[(0,e.jsx)(o,{className:"text-sm font-medium text-muted-foreground",children:s("rentals.dashboard.todayPickups")}),(0,e.jsx)(z,{className:"h-4 w-4 text-[#2fb380]"})]}),(0,e.jsxs)(c,{children:[(0,e.jsx)("div",{className:"text-3xl font-bold text-foreground",children:l.confirmedToday}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:s("rentals.dashboard.todayPickupsHint")})]})]}),(0,e.jsxs)(n,{className:"shadow-sm",children:[(0,e.jsxs)(i,{className:"flex flex-row items-center justify-between pb-2",children:[(0,e.jsx)(o,{className:"text-sm font-medium text-muted-foreground",children:s("rentals.dashboard.todayRevenue")}),(0,e.jsx)(Q,{className:"h-4 w-4 text-blue-500"})]}),(0,e.jsxs)(c,{children:[(0,e.jsx)("div",{className:"text-3xl font-bold text-foreground",children:new Intl.NumberFormat(h,{style:"currency",currency:"EUR"}).format(l.revenueToday)}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:s("rentals.dashboard.todayRevenueHint")})]})]}),(0,e.jsxs)(n,{className:"shadow-sm",children:[(0,e.jsxs)(i,{className:"flex flex-row items-center justify-between pb-2",children:[(0,e.jsx)(o,{className:"text-sm font-medium text-muted-foreground",children:s("rentals.dashboard.blockedVehicles")}),(0,e.jsx)(W,{className:"h-4 w-4 text-rose-500"})]}),(0,e.jsxs)(c,{children:[(0,e.jsx)("div",{className:"text-3xl font-bold text-foreground",children:l.blockedVehicles}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:s("rentals.dashboard.blockedVehiclesHint")})]})]})]}),(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)("h3",{className:"text-lg font-semibold tracking-tight text-foreground",children:s("rentals.dashboard.pickupsHeading")}),(0,e.jsx)(p,{asChild:!0,variant:"ghost",size:"sm",className:"gap-1 text-muted-foreground hover:text-foreground font-medium",children:(0,e.jsxs)(b,{to:`/sites/${r}/rentals/reservations`,children:[s("rentals.dashboard.allReservations")," ",(0,e.jsx)(F,{className:"h-4 w-4"})]})})]}),(0,e.jsx)(n,{className:"shadow-sm overflow-hidden border-border",children:g.length===0?(0,e.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(0,e.jsx)("div",{className:"mb-4 rounded-full bg-muted/50 p-4",children:(0,e.jsx)(M,{className:"h-8 w-8 text-muted-foreground opacity-40"})}),(0,e.jsx)("h4",{className:"font-semibold text-foreground",children:s("rentals.dashboard.empty")}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground mt-1 max-w-xs mx-auto",children:s("rentals.dashboard.emptyHint")})]}):(0,e.jsx)("div",{className:"divide-y divide-border/50",children:g.map(t=>(0,e.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between p-5 hover:bg-muted/30 transition-colors gap-4",children:[(0,e.jsxs)("div",{className:"flex items-center gap-4",children:[(0,e.jsx)("div",{className:"flex flex-col items-center justify-center bg-blue-500/10 text-blue-600 rounded-xl w-12 h-12 shrink-0 border border-blue-100",children:(0,e.jsx)(U,{className:"h-6 w-6"})}),(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"font-bold text-foreground leading-tight",children:t.customer_name}),(0,e.jsxs)("div",{className:"flex items-center gap-3 mt-1.5 flex-wrap",children:[(0,e.jsx)("p",{className:"text-sm font-semibold text-blue-600",children:t.vehicle?.name||s("rentals.common.vehicle")}),(0,e.jsx)("span",{className:"text-muted-foreground text-xs",children:"â¢"}),(0,e.jsxs)("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[(0,e.jsx)($,{className:"h-3 w-3"}),t.pickup_time||s("rentals.dashboard.timeTbd")]})]})]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-4 justify-between sm:justify-end",children:[(0,e.jsxs)("div",{className:"text-right hidden sm:block mr-2",children:[(0,e.jsx)("p",{className:"text-sm font-bold text-foreground",children:new Intl.NumberFormat(h,{style:"currency",currency:"EUR"}).format(Number(t.total_price||0))}),(0,e.jsx)("p",{className:"text-[10px] text-muted-foreground uppercase font-bold tracking-tighter",children:s("rentals.common.total")})]}),(0,e.jsx)("div",{className:"flex items-center gap-3",children:C(t.status)})]})]},t.id))})})]})]})}export{de 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.