1import{j as e,r as c,aW as f,e1 as N,h$ as b,L as y}from"./main-DO3vLohi.js";import{s as w,f as v,g as F,u as E}from"./concierge-triage-endpoints-CtnUGwXt.js";import{u as S}from"./useMutation-D1SAI5XB.js";import"./use-feature-flag-DMJB0GW8.js";function k({detail:s}){return e.jsxs("article",{className:"rounded border border-border p-4",children:[e.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-sm",children:[e.jsx("dt",{className:"font-medium text-text-muted",children:"From"}),e.jsx("dd",{className:"text-text",children:s.from}),e.jsx("dt",{className:"font-medium text-text-muted",children:"Subject"}),e.jsx("dd",{className:"text-text",children:s.subject?.trim()||"(no subject)"}),e.jsx("dt",{className:"font-medium text-text-muted",children:"Received"}),e.jsx("dd",{className:"text-text",children:new Date(s.receivedAt).toLocaleString()})]}),e.jsx("hr",{className:"my-4 border-border"}),s.hasBody?e.jsx("pre",{className:"whitespace-pre-wrap font-sans text-sm text-text",children:s.textBody}):e.jsx("p",{className:"text-sm text-text-muted italic",children:"No body available for this message."})]})}const j=2;function C({messageRef:s}){const[l,r]=c.useState(""),[d,i]=c.useState(""),[n,m]=c.useState(null),u=c.useId();c.useEffect(()=>{const t=setTimeout(()=>i(l.trim()),200);return()=>clearTimeout(t)},[l]);const o=f({queryKey:["ops","concierge-student-search",d],queryFn:()=>w({data:{query:d}}),enabled:d.length>=j}),x=o.data?.ok?o.data.students:[],a=S({mutationFn:t=>v({data:{messageRef:s,recipientUserId:t}}),onSuccess:t=>{t.ok&&m(null)}}),h=a.isError?"SEND_FAILED":a.data&&!a.data.ok?a.data.error.code:void 0,p=a.data?.ok?a.data.sentTo:null;return e.jsxs("div",{className:"rounded border border-border p-4",children:[e.jsx("h2",{className:"font-bold text-sm text-text",children:"Forward to a student"}),e.jsx("p",{className:"mt-1 text-text-muted text-xs",children:"Search for the student this message is really for. It is sent to their on-file email."}),e.jsx("input",{type:"search",value:l,onChange:t=>r(t.target.value),placeholder:"Search students by name or email","aria-label":"Search students by name or email","aria-controls":u,className:"mt-3 w-full rounded border border-border px-3 py-2 text-sm"}),o.isFetching?e.jsx("p",{className:"mt-2 text-text-muted text-xs",children:"Searchingâ¦"}):null,o.isError?e.jsx("p",{role:"alert",className:"mt-2 text-danger text-xs",children:"Couldn't search students. Try again."}):null,x.length>0?e.jsx("ul",{id:u,className:"mt-2 divide-y divide-border/60",children:x.map(t=>{const g=n?.userId===t.userId;return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>m(t),"aria-pressed":g,className:`flex w-full flex-col items-start px-2 py-2 text-left text-sm ${g?"bg-purple/10":"hover:bg-surface-muted"}`,children:[e.jsx("span",{className:"font-medium text-text",children:t.name?.trim()||t.email}),e.jsx("span",{className:"text-text-muted text-xs",children:t.email})]})},t.userId)})}):null,d.length>=j&&!o.isFetching&&!o.isError&&x.length===0?e.jsx("p",{className:"mt-2 text-text-muted text-xs",children:"No students found."}):null,e.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[e.jsx("button",{type:"button",disabled:!n||a.isPending,onClick:()=>n&&a.mutate(n.userId),className:"rounded-full bg-purple px-4 py-1.5 font-bold text-white text-xs disabled:opacity-50",children:a.isPending?"Forwardingâ¦":"Forward"}),n?e.jsxs("span",{className:"text-text-muted text-xs",children:["to ",n.name?.trim()||n.email]}):null]}),p?e.jsxs("p",{className:"mt-3 text-sm text-success",children:["Forwarded to ",p,"."]}):null,h?e.jsxs("p",{role:"alert",className:"mt-3 text-danger text-sm",children:["Couldn't forward the message (",h,"). Please try again."]}):null]})}function I(s){return N({queryKey:["ops","concierge-detail",s],queryFn:()=>F({data:{messageRef:s}})})}function D(){return e.jsx(y,{to:"/ops/apply",className:"mb-4 inline-block text-purple text-sm hover:underline",children:"â Back to queue"})}function R(){const{messageRef:s}=b.useParams(),l=E(),{data:r,isLoading:d,isError:i}=f({...I(s),enabled:l});return l?e.jsxs("div",{className:"mx-auto w-full max-w-3xl px-6 py-8",children:[e.jsx(D,{}),d?e.jsx("p",{className:"text-sm text-text-muted",children:"Loadingâ¦"}
1):i?e.jsx("p",{role:"alert",className:"text-sm text-danger",children:"Couldnât load this message. Try again."}):r?.ok?e.jsxs("div",{className:"space-y-6",children:[e.jsx(k,{detail:r.detail}),e.jsx(C,{messageRef:s})]}):e.jsx("p",{className:"text-sm text-danger",children:r&&"error"in r&&r.error.code==="FORBIDDEN"?"You donât have access to this message.":"Message not found."})]}):e.jsx("div",{className:"mx-auto w-full max-w-3xl px-6 py-8",children:e.jsx("p",{className:"text-sm text-text-muted",children:"This page isnât available."})})}export{R 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.