1import{j as e}from"./query-_koPiPsI.js";import{f as y,r as a}from"./react-vendor-h1rQ_Bae.js";import{f as _,s as c,L as v,B as f,R as b,C as p,n as h,o as C,p as S,k as j,g}from"./index-Dq2zLArw.js";import"./ui-radix-CKwvnS8F.js";import"./supabase-DL6nu9mS.js";import"./charts-Xu79y1bN.js";import"./motion-nVmI7L5T.js";const A=["new","in_progress","done","rejected"];function U(){const{user:r,loading:n}=_(),l=y(),[i,N]=a.useState(null),[o,w]=a.useState([]),[m,u]=a.useState(!0);a.useEffect(()=>{if(!n){if(!r){l("/auth");return}(async()=>{const{data:s}=await c.from("user_roles").select("role").eq("user_id",r.id).eq("role","admin").maybeSingle();N(!!s)})()}},[r,n,l]);const d=async()=>{u(!0);const{data:s}=await c.from("fix_requests").select("*").order("created_at",{ascending:!1}).limit(200);w(s??[]),u(!1)};a.useEffect(()=>{i&&d()},[i]);const q=async(s,t)=>{const{error:x}=await c.from("fix_requests").update({status:t}).eq("id",s);if(x)return g.error(x.message);g.success("Updated"),d()};return n||i===null?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(v,{className:"h-6 w-6 animate-spin"})}):i?e.jsxs("div",{className:"container mx-auto p-6 max-w-5xl space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Fix requests"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:'User "send to team" requests and "talk to founder" managed inquiries.'})]}),e.jsxs(f,{variant:"outline",size:"sm",onClick:d,disabled:m,children:[e.jsx(b,{className:`h-4 w-4 mr-2 ${m?"animate-spin":""}`})," Refresh"]})]}),o.length===0&&e.jsx(p,{children:e.jsx(h,{className:"py-10 text-center text-sm text-muted-foreground",children:"No requests yet."})}),o.map(s=>e.jsxs(p,{children:[e.jsx(C,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(S,{className:"text-base truncate",children:s.fix_title}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1 flex flex-wrap gap-2",children:[e.jsx(j,{variant:s.request_type==="managed_inquiry"?"default":"secondary",children:s.request_type==="managed_inquiry"?"Managed inquiry":"Fix request"}),s.target_platform&&e.jsx(j,{variant:"outline",children:s.target_platform}),e.jsxs("span",{children:["· ",new Date(s.created_at).toLocaleString()]}),e.jsxs("span",{className:"font-mono",children:["· user ",s.user_id.slice(0,8)]})]})]}),e.jsx("div",{className:"flex gap-1",children:A.map(t=>e.jsx(f,{size:"sm",variant:s.status===t?"default":"outline",className:"h-7 text-xs",onClick:()=>q(s.id,t),children:t},t))})]})}),e.jsxs(h,{className:"text-sm space-y-2",children:[s.fix_detail&&e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.fix_detail}),s.notes&&e.jsxs("div",{className:"rounded-md border p-2 bg-muted/30 text-xs whitespace-pre-wrap",children:[e.jsx("span",{className:"font-medium",children:"Notes: "}),s.notes]})]})]},s.id))]}):e.jsx("div",{className:"p-8 text-center text-muted-foreground",children:"Admin access required."})}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.