PageSourceSearch

https://recovery-automotive.lovable.app/assets/TechnicianDashboard-aI7X2w0W.js

js recovery-automotive.lovable.app collected 2026-10-03 03:42:20 UTC 4,793 bytes, 6 lines download raw bytes

1import{c as C,af as A,u as L,r as g,s as c,j as e,ay as M,b as d,B as P}from"./index-B8M9ps1T.js";import{u as q}from"./useQuery-CPNlGgE1.js";import{T as B,a as I,b as j,c as v}from"./tabs-zzllh7vg.js";import{C as k,a as b}from"./card-DzCf0Wp_.js";import{c as R,b as E,f as H,e as S}from"./use-technicians-BNgKEL-K.js";import{A as V}from"./arrow-right-BwLaIySX.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const W=C("Hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]),J={pending:"Pending",in_progress:"In Progress",parts_waiting:"Waiting for Parts",ready_for_review:"Ready for Review"},U=()=>{var u;const{user:a}=A(),l=L(),{data:i}=R(a==null?void 0:a.id),{punchOut:N,selfAssign:_}=E(),[,y]=g.useState(0);g.useEffect(()=>{const s=setInterval(()=>y(n=>n+1),3e4);return()=>clearInterval(s)},[]);const{data:r,isLoading:h}=q({queryKey:["tech-work-orders",a==null?void 0:a.id],enabled:!!a,queryFn:async()=>{const s="id, order_number, description, status, technician_id, vehicles(year, make, model)",n=["pending","in_progress","parts_waiting","ready_for_review"],[t,m,T]=await Promise.all([c.from("work_orders").select(s).eq("technician_id",a.id).is("archived_at",null).in("status",n).order("created_at",{ascending:!1}),c.from("work_orders").select(s).is("technician_id",null).is("archived_at",null).eq("status","pending").order("created_at",{ascending:!1}),c.from("jobs").select("work_order_id").eq("technician_id",a.id).eq("completed",!1)]);if(t.error)throw t.error;if(m.error)throw m.error;const x=[...new Set((T.data||[]).map(o=>o.work_order_id))].filter(o=>!(t.data||[]).some(O=>O.id===o));let f=[];return x.length&&(f=(await c.from("work_orders").select(s).in("id",x).is("archived_at",null).in("status",n)).data||[]),{mine:[...t.data||[],...f],open:m.data||[]}}}),w=s=>s.vehicles?[s.vehicles.year,s.vehicles.make,s.vehicles.model].filter(Boolean).join(" "):"No vehicle",p=({w:s,take:n})=>e.jsx(k,{children:e.jsxs(b,{className:"pt-6 flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-semibold",children:["WO #",s.order_number," · ",w(s)]}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:s.description||"No description"}),e.jsx(P,{variant:"outline",className:"mt-1",children:J[s.status]??s.status})]}),e.jsx("div",{className:"flex gap-2",children:n?e.jsxs(d,{onClick:async()=>{await _(s.id)&&l(`/dashboard/work-orders/${s.id}`)},children:[e.jsx(W,{className:"h-4 w-4 mr-1"})," Take This Job"]}):e.jsxs(d,{variant:"outline",onClick:()=>l(`/dashboard/work-orders/${s.id}`),children:["Open ",e.jsx(V,{className:"h-4 w-4 ml-1"})]})})]})});return e.jsxs("div",{className:"space-y-6",children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"My Jobs"}),i&&e.jsx(k,{className:"border-primary",children:e.jsxs(b,{className:"pt-6 flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(M,{className:"h-6 w-6 text-primary animate-pulse"}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-semibold",children:["Clocked in: ",((u=i.jobs)==null?void 0:u.description)??"Job"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[H(S(i))," so far"]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(d,{variant:"outline",onClick:()=>l(`/dashboard/work-orders/${i.work_order_id}`),children:"Open Order"}),e.jsx(d,{onClick:()=>N(),children:"Punch Out"})]})]})}),e.jsxs(B,{defaultValue:"mine",className:"space-y-4",children:[e.jsxs(I,{children:[e.jsxs(j,{value:"mine",children:["Assigned to Me (",(r==null?void 0:r.mine.length)??0,")"]}),e.jsxs(j,{value:"open",children:["Open Work Orders (",(r==null?void 0:r.open.length)??0,")"]})]}),e.jsx(v,{value:"mine",className:"space-y-3",children:h?e.jsx("p",{className:"text-muted-foreground",children:"Loading…"}):r!=null&&r.mine.length?r.mine.map(s=>e.jsx(p,{w:s},s.id)):e.jsx("p",{className:"text-muted-foreground",children:"Nothing assigned right now — check Open Work Orders to grab one."})}),e.jsx(v,{value:"open",className:"space-y-3",children:h?e.jsx("p",{className:"text-muted-foreground",children:"Loading…"}):r!=null&&r.open.length?r.open.map(s=>e.jsx(p,{w:s,take:!0},s.id)):e.jsx("p",{className:"text-muted-foreground",children:"No open w
6ork orders waiting for a tech."})})]})]})};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.