1import{j as e,r as d,ax as x,L as h,h as f,ab as g,k as y,av as j,s as b}from"./index-CzAkNt2W.js";import{R as N}from"./RequireRole-DhUlFC_T.js";import{C as w}from"./circle-check-gM2QolJ6.js";function v(){const[o,l]=d.useState([]),[i,n]=d.useState(null);async function c(){const s=await j()??"00000000-0000-0000-0000-000000000000",a=new Date;a.setHours(0,0,0,0);const t=new Date(a);t.setDate(t.getDate()+1);const{data:p,error:u}=await b.from("visits").select("id, scheduled_for, status, properties(address, city, customers(full_name))").eq("company_id",s).gte("scheduled_for",a.toISOString()).lt("scheduled_for",t.toISOString()).order("scheduled_for");n(u?"Today's route could not be loaded. Try again in a moment.":null),l((p??[]).map(r=>({...r,property:r.properties?{address:r.properties.address,city:r.properties.city,customer:r.properties.customers?{full_name:r.properties.customers.full_name}:void 0}:void 0})))}d.useEffect(()=>{c()},[]);const m=o.filter(s=>s.status==="completed").length;return e.jsxs("div",{className:"p-5 md:p-8 max-w-2xl",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-11 w-11 rounded-xl bg-water grid place-items-center",children:e.jsx(x,{className:"h-5 w-5 text-primary-foreground"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-3xl font-bold",children:"Today's route"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[m," of ",o.length," complete · ",new Date().toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric"})]})]})]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[i?e.jsx("div",{role:"alert",className:"rounded-2xl border border-destructive/40 p-4 text-sm text-destructive",children:i}):o.length===0?e.jsx("div",{className:"rounded-2xl border border-dashed border-border p-10 text-center text-sm text-muted-foreground",children:"No visits scheduled for today."}):null,o.map((s,a)=>{const t=s.status==="completed";return e.jsx(h,{to:"/visits/$id",params:{id:s.id},className:`block rounded-2xl border p-5 transition-all ${t?"border-border bg-muted/30 opacity-70":"border-border bg-card hover:shadow-pool hover:border-primary"}`,children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:`h-12 w-12 shrink-0 rounded-xl grid place-items-center font-display font-bold text-lg ${t?"bg-muted text-muted-foreground":"bg-water text-primary-foreground"}`,children:t?e.jsx(w,{className:"h-6 w-6"}):a+1}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-semibold text-lg",children:s.property?.customer?.full_name??"â"}),e.jsx(f,{variant:t?"secondary":"default",className:"text-[10px]",children:s.status})]}),e.jsxs("div",{className:"mt-1 text-sm text-muted-foreground flex flex-wrap gap-x-4 gap-y-1",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(g,{className:"h-3.5 w-3.5"}),new Date(s.scheduled_for).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(y,{className:"h-3.5 w-3.5"}),s.property?.address,s.property?.city?`, ${s.property.city}`:""]})]})]})]})},s.id)})]})]})}const C=()=>e.jsx(N,{allowed:["owner","office","technician"],children:e.jsx(v,{})});export{C 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.