1import{j as e}from"./radix-C7m_p3hd.js";import{u as L,L as B,s as b,t as y}from"./index-QwT9_GrP.js";import{a as t,au as T,P}from"./icons-Byb5nA6I.js";import{B as g}from"./button-aZOsfQvV.js";import{I as O}from"./input-BDda6t1w.js";import{L as N}from"./label-Cywe519D.js";import{T as R}from"./textarea-DIbiZgd6.js";import{C as c,b as k,c as S,a as n}from"./card-WJomPFy5.js";import{B as o}from"./badge-CL86Vhfo.js";import{S as E,a as F,b as _,c as A,d as D}from"./sheet-CqEFehDD.js";import{L as H}from"./ListRow-Dr6GWK9v.js";import{P as I}from"./PullToRefresh-K3T3NmBA.js";import{S as $}from"./StickyActionBar-CLlSMB0z.js";import"./pdf-BQaX5Z90.js";import"./editor-BVBPyX6q.js";import"./charts-CkbpeChh.js";import"./index-DpFz0cJn.js";import"./use-haptic-D9-71G6K.js";function re(){const{user:a}=L(),[i,v]=t.useState(null),[l,d]=t.useState(""),[m,u]=t.useState(""),[x,h]=t.useState(!1),[w,p]=t.useState(!1);async function r(){const{data:s}=await b.from("tickets").select("id,subject,body,status,priority,created_at").order("created_at",{ascending:!1});v(s??[])}t.useEffect(()=>{a&&r()},[a]);async function C(s){if(s.preventDefault(),!a)return;h(!0);const{error:f}=await b.from("tickets").insert({client_id:a.id,subject:l.trim(),body:m.trim()||null});if(h(!1),f){y.error(f.message);return}y.success("Ticket submitted"),d(""),u(""),p(!1),r()}const j=e.jsxs("form",{onSubmit:C,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"subject",children:"Subject"}),e.jsx(O,{id:"subject",required:!0,maxLength:200,value:l,onChange:s=>d(s.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"body",children:"Details"}),e.jsx(R,{id:"body",rows:5,maxLength:2e3,value:m,onChange:s=>u(s.target.value)})]}),e.jsx(g,{type:"submit",disabled:x,className:"w-full bg-gradient-fire md:w-auto",children:x?"Submitting...":"Submit ticket"})]});return e.jsxs(I,{onRefresh:r,children:[e.jsxs("div",{className:"mx-auto max-w-5xl space-y-6 pb-20 md:pb-0",children:[e.jsxs("div",{className:"hidden md:block",children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Support"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Open a ticket â we typically reply within a business day."})]}),e.jsxs(c,{className:"hidden md:block",children:[e.jsx(k,{children:e.jsx(S,{children:"New ticket"})}),e.jsx(n,{children:j})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-base font-semibold md:text-lg",children:"Your tickets"}),i===null?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."}):i.length===0?e.jsx(c,{children:e.jsx(n,{className:"py-10 text-center text-sm text-muted-foreground",children:"No tickets yet."})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-2 md:hidden",children:i.map(s=>e.jsx(H,{to:`/app/tickets/${s.id}`,leading:e.jsx(T,{className:"h-5 w-5 text-primary-strong"}),title:s.subject,subtitle:s.body??"No details",meta:e.jsx(o,{variant:s.status==="open"?"default":"secondary",className:"capitalize",children:s.status})},s.id))}),e.jsx("div",{className:"hidden space-y-3 md:block",children:i.map(s=>e.jsx(B,{to:"/app/tickets/$id",params:{id:s.id},className:"block transition hover:opacity-90",children:e.jsxs(c,{children:[e.jsxs(k,{className:"flex-row items-center justify-between space-y-0",children:[e.jsx(S,{className:"text-base",children:s.subject}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(o,{variant:"outline",children:s.priority}),e.jsx(o,{variant:s.status==="open"?"default":"secondary",children:s.status})]})]}),s.body&&e.jsx(n,{className:"text-sm text-muted-foreground line-clamp-2",children:s.body})]})},s.id))})]})]})]}),e.jsxs(E,{open:w,onOpenChange:p,children:[e.jsx($,{withBottomNav:!0,children:e.jsx(F,{asChild:!0,children:e.jsxs(g,{className:"w-full rounded-full bg-gradient-fire text-base font-semibold tap-press",children:[e.jsx(P,{className:"h-4 w-4"})," New ticket"]})})}),e.jsxs(_,{side:"bottom",className:"rounded-t-3xl p-5",children:[e.jsx(A,{className:"mb-4 text-left",children:e.jsx(D,{children:"New ticket"})}),j]})]})]})}export{re 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.