1import{x as j,u as x,j as e,C as a,b as l,T,a4 as m,f as p,e as g,az as $,m as f,M as N,B as q,aG as B,n as o}from"./index-Bk9vt8H7.js";import{P as S}from"./phone-45lJIVx7.js";function V(){const[v,b]=j.useState(new Date);j.useEffect(()=>{const s=setInterval(()=>b(new Date),1e3);return()=>clearInterval(s)},[]);const{data:h,refetch:E}=x({queryKey:["live-bookings"],queryFn:()=>o.entities.Booking.list("-pickup_datetime"),initialData:[],refetchInterval:1e4}),{data:d}=x({queryKey:["drivers"],queryFn:()=>o.entities.Driver.list(),initialData:[]}),{data:y}=x({queryKey:["vehicles"],queryFn:()=>o.entities.Vehicle.list(),initialData:[]}),i=h.filter(s=>["assigned","en_route","arrived","in_progress"].includes(s.status)),w=h.filter(s=>{const t=new Date(s.pickup_datetime),r=new Date;return t.toDateString()===r.toDateString()}),_=d.filter(s=>i.some(t=>t.driver_id===s.id)).length,c=d.filter(s=>s.status==="available").length,D={assigned:"bg-purple-500/20 text-purple-400 border-purple-500/50",en_route:"bg-blue-500/20 text-blue-400 border-blue-500/50",arrived:"bg-cyan-500/20 text-cyan-400 border-cyan-500/50",in_progress:"bg-green-500/20 text-green-400 border-green-500/50"},A=s=>d.find(t=>t.id===s),F=s=>y.find(t=>t.id===s);return e.jsx("div",{className:"min-h-screen bg-background p-4 md:p-8",children:e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex justify-between items-start mb-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-foreground mb-2",children:"Live Tracking"}),e.jsx("p",{className:"text-muted-foreground",children:"Real-time trip and driver monitoring"})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Current Time"}),e.jsx("p",{className:"text-xl font-semibold text-foreground",children:v.toLocaleTimeString()})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(a,{className:"bg-card border-border",children:e.jsx(l,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-green-500/20 flex items-center justify-center",children:e.jsx(T,{className:"w-5 h-5 text-green-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Active Trips"}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:i.length})]})]})})}),e.jsx(a,{className:"bg-card border-border",children:e.jsx(l,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:e.jsx(m,{className:"w-5 h-5 text-blue-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"On Duty"}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:_})]})]})})}),e.jsx(a,{className:"bg-card border-border",children:e.jsx(l,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-purple-500/20 flex items-center justify-center",children:e.jsx(m,{className:"w-5 h-5 text-purple-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Available"}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:c})]})]})})}),e.jsx(a,{className:"bg-card border-border",children:e.jsx(l,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-orange-500/20 flex items-center justify-center",children:e.jsx(p,{className:"w-5 h-5 text-orange-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Today"}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:w.length})]})]})})})]})]}),i.length===0?e.jsx(a,{className:"bg-card border-border",children:e.jsxs(l,{className:"p-12 text-center",children:[e.jsx(g,{className:"w-16 h-16 text-[#D4AF37] mx-auto mb-4"}),e.jsx("h3",{className:"text-xl font-semibold text-foreground mb-2",children:"No Active Trips"}),e.jsx("p",{className:"text-muted-foreground",children:"All drivers are currently available"})]})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h2",{className:"text-xl font-bold text-foreground",children:["Active Trips (",i.length,")"]}),i.map((s,t)=>{var u;const r=A(s.driver_id),n=F(s.vehicle_id);return e.jsx($.div,{initial:{opacity:0,y:20}
1,animate:{opacity:1,y:0},transition:{delay:t*.05},children:e.jsx(a,{className:"bg-card border-border hover:border-[#D4AF37] transition-all",children:e.jsx(l,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx(f,{className:`${D[s.status]} border`,children:s.status.replace(/_/g," ").toUpperCase()}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["#",s.booking_number]}),e.jsx("span",{className:"text-sm text-[#D4AF37]",children:new Date(s.pickup_datetime).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[e.jsx(N,{className:"w-4 h-4 text-green-400 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground",children:"Pickup"}),e.jsx("p",{className:"text-foreground",children:s.pickup_address})]})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[e.jsx(N,{className:"w-4 h-4 text-red-400 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground",children:"Dropoff"}),e.jsx("p",{className:"text-foreground",children:s.dropoff_address})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[e.jsx(m,{className:"w-4 h-4 text-[#D4AF37] mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground",children:"Customer"}),e.jsx("p",{className:"text-foreground",children:s.customer_name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.customer_phone})]})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[e.jsx(p,{className:"w-4 h-4 text-[#D4AF37] mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground",children:"Distance & Duration"}),e.jsxs("p",{className:"text-foreground",children:[(u=s.estimated_distance_miles)==null?void 0:u.toFixed(1)," mi ⢠",s.estimated_duration_minutes," min"]})]})]})]})]})]}),e.jsxs("div",{className:"lg:w-64 space-y-4",children:[r?e.jsx(a,{className:"bg-muted border-input",children:e.jsxs(l,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("div",{className:"w-12 h-12 bg-card rounded-full flex items-center justify-center",children:r.photo_url?e.jsx("img",{src:r.photo_url,alt:r.full_name,className:"w-full h-full rounded-full object-cover"}):e.jsx("span",{className:"text-[#D4AF37] font-semibold",children:r.full_name[0]})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-semibold text-foreground",children:r.full_name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Driver"})]})]}),n&&e.jsx("div",{className:"mb-3 pb-3 border-b border-input",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(g,{className:"w-4 h-4 text-[#D4AF37]"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-foreground",children:n.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n.license_plate})]})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("a",{href:`tel:${r.phone}`,className:"flex items-center justify-center gap-2 text-sm text-[#D4AF37] hover:text-[#F4E4C1] transition-colors",children:[e.jsx(S,{className:"w-4 h-4"}),"Call Driver"]}),e.jsxs(q,{variant:"outline",size:"sm",className:"w-full border-input text-foreground hover:bg-card",onClick:()=>{const C=`https://www.google.com/maps/dir/?api=1&origin=${s.pickup_lat},${s.pickup_lng}&destination=${s.dropoff_lat},${s.dropoff_lng}`;window.open(C,"_blank")},children:[e.jsx(B,{className:"w-4 h-4 mr-2"}),"View Route"]})]})]})}):e.jsx("div",{className:"text-center py-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No driver assigned"})}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Trip Value"}),e.jsxs("p",{className:"text-2xl font-bold text-[#D4AF37]",children:["$",s.total_amount.toFixed(2)]})]})]})]})})})},s.id)})]}),c>0&&e.jsxs("div",{className:"mt-8",children:[e.jsxs("h2",{className:"text-xl font-bold text-foreground mb-4",children:["Available Drivers (",c,")"]}),e.jsx("div",{className:"grid md:grid-cols-2 lg:grid-cols-3 gap-4",children:d.filter(s=>s.status==="available").map(s=>e.jsx(a,{className:"bg-card border-border",children:e.jsx(l,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-muted rounded-full flex items-center justify-center",children:s.photo_url?e.jsx("img",{src:s.photo_url,alt:s.full_name,className:"w-full h-full rounded-full object-cover"}):e.jsx("span",{className:"text-[#D4AF37] font-semibold",children:s.full_name[0]})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-semibold text-foreground",children:s.full_name}),e.jsx(f,{className:"bg-green-500/20 text-green-400 border-green-500/50 text-xs",children:"Available"})]})]})})},s.id))})]})]})})}export{V 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.