1import{x as T,k as I,m as D,r as l,j as e}from"./vendor-_7wHzwhe.js";import{u as _}from"./useQuery-Dw2D-494.js";import{n as A,u as L,B as m,p as f,t as j,aS as q,aT as H,T as M,au as Q}from"./index-BxaSwYnP.js";import{u as N}from"./useMutation-DOAYxB4-.js";import{C as $}from"./checkbox-CAbCpZJT.js";import{L as x}from"./loader-circle-BUTbyqAc.js";import"./framer-motion-BC1ef0HS.js";const u="inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-[10.5px] font-bold";function B(s){return s==="Approved"?`${u} border border-blue-500/25 bg-blue-500/15 text-blue-600 dark:text-blue-400`:s==="In-Flight"?`${u} border border-teal-500/25 bg-teal-500/15 text-teal-600 dark:text-teal-400`:`${u} border border-muted-foreground/15 bg-muted-foreground/10 text-muted-foreground`}function p({message:s}){return e.jsxs("div",{className:"flex items-center gap-2.5 rounded-xl border border-red-500/25 bg-red-500/10 px-4 py-3 text-sm text-red-600 dark:text-red-400",children:[e.jsx(M,{className:"h-4 w-4 shrink-0"})," ",s]})}function U(){const{ticketId:s=""}=T(),v=I(),{pathname:h}=D(),y=h.startsWith("/admin")?"/admin/schedule":h.startsWith("/cfi")?"/cfi/schedule":"/student",{toast:n}=A(),k=L(),[d,w]=l.useState(!1),[o,C]=l.useState(""),[c,S]=l.useState(""),{data:E=[],isLoading:F,error:g,refetch:P}=_({queryKey:["aod_tickets"],queryFn:()=>Q()}),t=E.find(r=>r.id===s),b=()=>{k.invalidateQueries({queryKey:["aod_tickets"]})},a=N({mutationFn:()=>q(s,d),onSuccess:()=>{n({title:"Dispatched",description:"Aircraft is now In-Flight."}),b()},onError:r=>n({title:"Dispatch failed",description:r.message,variant:"destructive"})}),i=N({mutationFn:()=>H(s,Number(o),Number(c)),onSuccess:()=>{n({title:"Checked in",description:"Sent to your instructor for verification."}),b(),v(y)},onError:r=>n({title:"Check-in failed",description:r.message,variant:"destructive"})});return F?e.jsx("div",{className:"flex justify-center py-16 text-muted-foreground",children:e.jsx(x,{className:"h-5 w-5 animate-spin"})}):g?e.jsxs("div",{className:"mx-auto max-w-lg space-y-3",children:[e.jsx(p,{message:g.message}),e.jsx(m,{variant:"outline",size:"sm",className:"border-border",onClick:()=>P(),children:"Retry"})]}):t?e.jsxs("div",{className:"mx-auto max-w-lg",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-2xl font-bold text-foreground",children:"Preflight & Dispatch"}),e.jsxs("p",{className:"mt-0.5 text-sm text-muted-foreground",children:[t.aircraft_tail?e.jsxs(e.Fragment,{children:["Aircraft ",e.jsx("span",{className:"font-mono font-semibold text-foreground",children:t.aircraft_tail})]}):"Flight dispatch",t.scheduled_start?e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"font-mono text-xs",children:new Date(t.scheduled_start).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}):null]})]}),e.jsx("span",{className:B(t.status),children:t.status})]}),t.status==="Approved"&&e.jsxs("div",{className:"mt-6 space-y-4 rounded-2xl border border-border bg-card p-5 shadow-card",children:[e.jsx("p",{className:"text-[10.5px] font-bold uppercase tracking-wider text-muted-foreground",children:"Preflight Checklist"}),e.jsx("p",{className:"rounded-lg border border-border bg-background/60 px-3.5 py-2.5 text-[12.5px] text-muted-foreground",children:"Starting Hobbs/Tach are captured automatically from the aircraft at dispatch."}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-3 rounded-lg border border-primary/25 bg-primary/5 px-3.5 py-3 transition-colors hover:border-primary/40",children:[e.jsx($,{checked:d,onCheckedChange:r=>w(r===!0)}),e.jsxs("span",{className:"text-[13.5px] text-foreground/90",children:[e.jsx("span",{className:"block text-[10px] font-bold uppercase tracking-wider text-primary",children:"Pilot Declaration"}),"I have completed the preflight inspection."]})]}),a.isError&&e.jsx(p,{message:a.error.message}),e.jsxs(m,{className:"w-full bg-gradient-primary font-semibold shadow-glow hover:opacity-90",disabled:!d||a.isPending,onClick:()=>a.mutate(),children:[a.isPending?e.jsx(x,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Dispatch"]})]}),t.status==="In-Flight"&&e.jsxs("div",{className:"mt-6 space-y-4 rounded-2xl border border-border bg-card p-5 shadow-card",children:[e.jsx("p",{className:"text-[10.5px] font-bold uppercase tracking-wider text-muted-foreground",children:"Post-Flight Check-In"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"rounded-xl border border-primary/25 bg-primary/10 px-4 py-3 text-center",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Starting Hobbs"}),e.jsx("div",{className:"mt-1 font-mono text-2xl font-extrabold leading-none text-primary",children:t.hobbs_start})]}),e.jsxs("div",{className:"rounded-xl border border-primary/25 bg-primary/10 px-4 py-3 text-center",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Starting Tach"}),e.jsx("div",{className:"mt-1 font-mono text-2xl font-extrabold leading-none text-primary",children:t.tach_start})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(f,{className:"text-[10.5px] font-bold uppercase tracking-wider text-muted-foreground",children:"Ending Hobbs"}),e.jsx(j,{className:"mt-1.5 h-10 font-mono text-base font-semibold",type:"number",min:"0",step:"0.1",value:o,onChange:r=>C(r.target.value)})]}),e.jsxs("div",{children:[e.jsx(f,{className:"text-[10.5px] font-bold uppercase tracking-wider text-muted-foreground",children:"Ending Tach"}),e.jsx(j,{className:"mt-1.5 h-10 font-mono text-base font-semibold",type:"number",min:"0",step:"0.1",value:c,onChange:r=>S(r.target.value)})]})]}),i.isError&&e.jsx(p,{message:i.error.message}),e.jsxs(m,{className:"w-full bg-gradient-primary font-semibold shadow-glow hover:opacity-90",disabled:o===""||c===""||i.isPending,onClick:()=>i.mutate(),children:[i.isPending?e.jsx(x,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Submit Check-In"]})]}),!["Approved","In-Flight"].includes(t.status)&&e.jsx("div",{className:"mt-6 rounded-2xl border border-border bg-card p-6 text-center shadow-card",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No action available for this flight right now."})})]}):e.jsx("div",{className:"mx-auto max-w-lg rounded-2xl border border-border bg-card p-6 text-center shadow-card",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Flight not found."})})}export{U 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.