1import{r as o,j as e}from"./react-vendor-C-_weJGF.js";import{b as p,u as j,c as g}from"./query-DA-B5yju.js";import{B as c,s as m,a as y}from"./index-DiEum5Ju.js";import{A as v}from"./AdminLayout-Byts1X3Z.js";import{C as d}from"./card-D9fxEFKG.js";import{B as r}from"./badge-TGWIF5-T.js";import{S as N,a as w,b as k,c as S,d as i}from"./select-CQ7qceit.js";import{E as _,X as F}from"./icons-BZJMmL1V.js";import"./radix-CMA3xQgM.js";import"./supabase-BppBjPB2.js";import"./motion-CfmjrLVm.js";import"./logo-BWhOaj1e.js";function I(){const x=p(),[t,u]=o.useState("all"),{data:n=[]}=j({queryKey:["admin-bookings"],queryFn:async()=>{const{data:s}=await m.from("bookings").select("*").order("starts_at",{ascending:!1});return s||[]}}),l=o.useMemo(()=>t==="all"?n:n.filter(s=>(s.site||"streamline")===t),[n,t]),h=s=>s==="roof_report_360"?"Roof Report 360":"Streamline",f=g({mutationFn:async s=>{const{error:a}=await m.from("bookings").update({status:"cancelled"}).eq("id",s);if(a)throw a},onSuccess:()=>{x.invalidateQueries({queryKey:["admin-bookings"]}),y.success("Booking cancelled (note: this does NOT delete the Google Calendar event)")}});return e.jsx(v,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-end justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Bookings"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"All meetings booked through your sites."})]}),e.jsxs("div",{className:"w-56",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Filter by site"}),e.jsxs(N,{value:t,onValueChange:u,children:[e.jsx(w,{children:e.jsx(k,{})}),e.jsxs(S,{children:[e.jsx(i,{value:"all",children:"All sites"}),e.jsx(i,{value:"streamline",children:"Streamline Factory"}),e.jsx(i,{value:"roof_report_360",children:"Roof Report 360"})]})]})]})]}),l.length===0?e.jsx(d,{className:"p-8 text-center text-muted-foreground",children:"No bookings yet."}):l.map(s=>{const a=new Intl.DateTimeFormat("en-US",{dateStyle:"full",timeStyle:"short",timeZone:s.timezone}).format(new Date(s.starts_at));return e.jsx(d,{className:"p-5",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold",children:s.meeting_type_label}),e.jsxs(r,{variant:"outline",children:[s.duration_minutes," min"]}),e.jsx(r,{variant:s.status==="cancelled"?"destructive":"default",children:s.status}),e.jsx(r,{variant:"secondary",children:h(s.site||"streamline")}),e.jsx(r,{variant:"secondary",children:s.source})]}),e.jsxs("p",{className:"text-sm text-foreground",children:[a," (",s.timezone,")"]}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:[e.jsx("strong",{children:s.name})," · ",e.jsx("a",{className:"underline",href:`mailto:${s.email}`,children:s.email}),s.phone&&e.jsxs(e.Fragment,{children:[" · ",s.phone]}),s.company&&e.jsxs(e.Fragment,{children:[" · ",s.company]})]}),s.notes&&e.jsx("p",{className:"text-sm text-muted-foreground mt-2 whitespace-pre-wrap",children:s.notes})]}),e.jsxs("div",{className:"flex flex-col gap-2 shrink-0",children:[s.meet_url&&e.jsx("a",{href:s.meet_url,target:"_blank",rel:"noopener noreferrer",children:e.jsxs(c,{size:"sm",variant:"outline",children:[e.jsx(_,{className:"w-4 h-4 mr-1"})," Meet"]})}),s.status!=="cancelled"&&e.jsxs(c,{size:"sm",variant:"ghost",onClick:()=>f.mutate(s.id),children:[e.jsx(F,{className:"w-4 h-4 mr-1"})," Cancel"]})]})]})},s.id)})]})})}export{I 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.