import{r as i,u as h,j as e,H as j}from"./app-BRoRPa4x.js";import{A as f}from"./AdminLayout-DCcA2Aje.js";import{T as y,I as b}from"./TextInput-B6_WtKv0.js";import{P as g}from"./PrimaryButton-CI9diFCm.js";import{f as N}from"./format-ByEjdobp.js";import"./Dropdown-B4bpLCgK.js";import"./transition-u43f5Dc-.js";import"./proxy-iYr3ghlA.js";import"./sweetalert2.esm.all-UgF8mXO5.js";import"./ChevronRightIcon-BDYMGWwz.js";import"./en-US-IqjfvMWk.js";function $({auth:r,conversation:t,messages:a}){const o=i.useRef(null),{data:m,setData:l,post:n,processing:c,errors:x,reset:u}=h({body:"",conversation_id:t.id}),d=()=>{var s;(s=o.current)==null||s.scrollIntoView({behavior:"smooth"})};i.useEffect(()=>{d()},[a]);const p=s=>{s.preventDefault(),n(route("admin.messages.store"),{onSuccess:()=>{u("body"),d()},preserveScroll:!0})};return e.jsxs(f,{user:r.user,header:e.jsxs("h2",{className:"font-semibold text-xl text-gray-800 leading-tight",children:["Conversation with ",t.user.name," and ",t.doctor.name]}),children:[e.jsx(j,{title:`Conversation: ${t.subject||"No Subject"}`}),e.jsx("div",{className:"py-12",children:e.jsx("div",{className:"max-w-3xl mx-auto sm:px-6 lg:px-8",children:e.jsx("div",{className:"bg-white overflow-hidden shadow-sm sm:rounded-lg",children:e.jsxs("div",{className:"p-6 text-gray-900",children:[e.jsxs("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:["Subject: ",t.subject||"No Subject"]}),e.jsxs("div",{className:"h-96 overflow-y-auto border border-gray-200 rounded-lg p-4 mb-4",children:[a.map(s=>e.jsx("div",{className:`flex mb-4 ${s.sender_id===r.user.id?"justify-end":"justify-start"}`,children:e.jsxs("div",{className:`max-w-[70%] p-3 rounded-lg ${s.sender_id===r.user.id?"bg-indigo-500 text-white":"bg-gray-200 text-gray-800"}`,children:[e.jsx("p",{className:"text-sm font-medium",children:s.sender.name}),e.jsx("p",{className:"text-sm mt-1",children:s.body}),e.jsx("p",{className:"text-xs text-right mt-1 opacity-75",children:N(new Date(s.created_at),"MMM d, yyyy h:mm a")})]})},s.id)),e.jsx("div",{ref:o})]}),e.jsxs("form",{onSubmit:p,className:"flex items-center space-x-2",children:[e.jsx(y,{id:"body",name:"body",value:m.body,className:"flex-1",onChange:s=>l("body",s.target.value),placeholder:"Type your message..."}),e.jsx(g,{disabled:c,children:"Send"}),e.jsx(b,{message:x.body,className:"mt-2"})]})]})})})})]})}export{$ as default};
