import{d as e,f as t,h as n,l as r,s as i,t as a,u as o}from"./src-C0xjWfnx.js";import{n as s}from"./trpc-client-QrVjRqP1.js";import{t as c}from"./createLucideIcon-7nArgiy8.js";import{t as l}from"./message-square-BE-hnHXL.js";var u=c(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),d=n(t()),f=e();function p(){let{data:e}=s.user.complaint.getAll.useQuery(),t=s.user.complaint.raise.useMutation(),n=s.useUtils(),[c,p]=(0,d.useState)(!1),[m,h]=(0,d.useState)(``),g=e?.data||[];return(0,f.jsxs)(a,{children:[(0,f.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,f.jsx)(o,{weight:`bold`,className:`text-xl`,children:`Help & Complaints`}),(0,f.jsxs)(i,{onClick:()=>p(!c),className:`flex items-center gap-1 text-brand-600`,children:[(0,f.jsx)(u,{className:`h-4 w-4`}),(0,f.jsx)(o,{className:`text-sm`,children:`New`})]})]}),c&&(0,f.jsxs)(`div`,{className:`mb-6 rounded-xl border border-gray-100 bg-white p-4 shadow-sm`,children:[(0,f.jsx)(o,{weight:`semibold`,className:`mb-3`,children:`Raise a Complaint`}),(0,f.jsx)(`textarea`,{className:`mb-3 min-h-24 w-full rounded-lg border border-gray-200 p-3 text-sm`,value:m,onChange:e=>h(e.target.value),placeholder:`Describe your issue...`,rows:4}),(0,f.jsx)(r,{onClick:()=>{m.trim()&&t.mutate({body:m.trim()},{onSuccess:()=>{h(``),p(!1),n.user.complaint.getAll.invalidate()}})},disabled:t.isPending||!m.trim(),textContent:t.isPending?`Submitting...`:`Submit`})]}),g.length===0?(0,f.jsxs)(`div`,{className:`flex flex-col items-center gap-4 py-20`,children:[(0,f.jsx)(l,{className:`h-12 w-12 text-gray-300`}),(0,f.jsx)(o,{className:`text-gray-500`,children:`No complaints yet`})]}):(0,f.jsx)(`div`,{className:`flex flex-col gap-3`,children:g.map(e=>(0,f.jsxs)(`div`,{className:`rounded-xl border border-gray-100 bg-white p-4 shadow-sm`,children:[(0,f.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,f.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs font-medium ${e.status===`resolved`?`bg-green-100 text-green-700`:`bg-yellow-100 text-yellow-700`}`,children:e.status||`pending`}),(0,f.jsx)(o,{className:`text-xs text-gray-400`,children:e.createdAt?new Date(e.createdAt).toLocaleDateString():``})]}),(0,f.jsx)(o,{className:`text-sm text-gray-700`,children:e.body}),e.adminResponse&&(0,f.jsx)(`div`,{className:`mt-2 rounded-lg bg-blue-50 p-2`,children:(0,f.jsxs)(o,{className:`text-xs text-blue-600`,children:[`Response: `,e.adminResponse]})})]},e.id))})]})}export{p as component};