1import{r as c,j as e}from"./vendor-react-DKbe1Umz.js";import{H as b,L as d,T as g,B as y,o as N}from"./index-DZ74KeH3.js";import{u as v,a as w}from"./vendor-data-CjSe2wkl.js";import{c0 as u,i as k,Y as S,bS as x}from"./vendor-ui-DMaW9-Ov.js";import"./vendor-charts-DWX9qznF.js";import"./vendor-dates-5UNeOyFW.js";import"./vendor-forms-C2vWC2ab.js";function R({value:r,onChange:a}){const[l,n]=c.useState(0);return e.jsx("div",{className:"flex gap-2 justify-center","data-testid":"csat-star-rating",children:[1,2,3,4,5].map(t=>e.jsx("button",{type:"button",onClick:()=>a(t),onMouseEnter:()=>n(t),onMouseLeave:()=>n(0),className:"focus:outline-none","data-testid":`star-${t}`,"aria-label":`${t} star${t!==1?"s":""}`,children:e.jsx(x,{className:`h-10 w-10 transition-colors ${t<=(l||r)?"fill-yellow-400 text-yellow-400":"text-gray-300"}`})},t))})}const C=["","Poor","Fair","Good","Very Good","Excellent"];function Y(){const{token:r}=b(),[a,l]=c.useState(0),[n,t]=c.useState(""),[m,p]=c.useState(!1),{data:o,isLoading:h,error:f}=v({queryKey:["/api/support/csat",r],queryFn:()=>fetch(`/api/support/csat/${r}`).then(s=>{if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}),retry:!1}),i=w({mutationFn:async()=>{const s=await N("POST",`/api/support/csat/${r}`,{score:a,comment:n.trim()||void 0});if(!s.ok){const j=await s.json().catch(()=>({}));throw new Error(j.error||"Failed to submit rating")}return s.json()},onSuccess:()=>{p(!0)}});return h?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx(u,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):f||!o?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center space-y-3 max-w-sm mx-auto px-4",children:[e.jsx(k,{className:"h-12 w-12 text-muted-foreground mx-auto"}),e.jsx("h1",{className:"text-xl font-semibold",children:"Rating Link Unavailable"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"This rating link is invalid or has expired. Rating links are valid for 7 days after resolution."})]})}):o.alreadyRated||m?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center space-y-4 max-w-sm mx-auto px-4",children:[e.jsx(S,{className:"h-14 w-14 text-green-500 mx-auto","data-testid":"icon-csat-submitted"}),e.jsx("h1",{className:"text-2xl font-bold",children:"Thank you!"}),e.jsx("p",{className:"text-muted-foreground",children:o.alreadyRated&&!m?"You've already rated this ticket.":"Your feedback has been received. We appreciate you taking the time!"})]})}):e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center px-4",children:e.jsxs("div",{className:"w-full max-w-md
1space-y-6",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/10 mb-2",children:e.jsx(x,{className:"h-8 w-8 text-primary"})}),e.jsx("h1",{className:"text-2xl font-bold","data-testid":"heading-csat",children:"Rate your support experience"}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:['Your ticket "',e.jsx("span",{className:"font-medium",children:o.ticket.subject}),'" has been resolved.']})]}),e.jsxs("div",{className:"rounded-xl border bg-card p-6 space-y-6 shadow-sm",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(d,{className:"block text-center text-sm font-medium",children:"How would you rate our support?"}),e.jsx(R,{value:a,onChange:l}),a>0&&e.jsx("p",{className:"text-center text-sm font-medium text-primary","data-testid":"text-star-label",children:C[a]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(d,{htmlFor:"csat-comment",className:"text-sm",children:["Comments ",e.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),e.jsx(g,{id:"csat-comment",value:n,onChange:s=>t(s.target.value),placeholder:"Tell us more about your experienceâ¦",rows:3,maxLength:2e3,"data-testid":"input-csat-comment"})]}),i.error&&e.jsx("p",{className:"text-sm text-destructive","data-testid":"text-csat-error",children:i.error.message}),e.jsxs(y,{className:"w-full",disabled:a===0||i.isPending,onClick:()=>i.mutate(),"data-testid":"button-csat-submit",children:[i.isPending?e.jsx(u,{className:"h-4 w-4 animate-spin mr-2"}):null,"Submit Rating"]})]}),e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:"SmartManageAI Support · Your feedback helps us improve"})]})})}export{Y 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.