1"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[816],{2264(e,t,s){s.d(t,{p:()=>d});var a=s(9379),r=s(3986),n=s(5043),l=s(9766),i=s(579);const c=["className","type"],d=n.forwardRef((e,t)=>{let{className:s,type:n}=e,d=(0,r.A)(e,c);return(0,i.jsx)("input",(0,a.A)({type:n,className:(0,l.cn)("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",s),ref:t},d))});d.displayName="Input"},2816(e,t,s){s.r(t),s.d(t,{default:()=>b});var a=s(5043),r=s(5685),n=s(9722),l=s(5016),i=s(3390),c=s(2264),d=s(2024),o=s(193),m=s(5746),x=s(6328),u=s(3862),h=s(579);function f(e){let{conversations:t,selected:s,onSelect:a}=e;return(0,h.jsxs)("div",{className:"space-y-1",children:[0===t.length&&(0,h.jsxs)("div",{className:"text-center py-8",children:[(0,h.jsx)(o.A,{className:"w-8 h-8 text-slate-600 mx-auto mb-2"}),(0,h.jsx)("p",{className:"text-slate-500 text-sm",children:"No messages yet"}),(0,h.jsx)("p",{className:"text-slate-600 text-xs mt-1",children:"Visit a profile and send a message to start a conversation"})]}),t.map(e=>{var t,r;return(0,h.jsxs)("button",{onClick:()=>a(e),className:"w-full flex items-center gap-3 p-3 rounded-xl transition-all text-left ".concat((null===s||void 0===s?void 0:s.partner_id)===e.partner_id?"bg-[#D4AF37]/8 border border-[#D4AF37]/15":"bg-white/[0.02] border border-transparent hover:bg-white/5"),"data-testid":"convo-".concat(e.partner_id),children:[(0,h.jsx)("div",{className:"w-10 h-10 rounded-full bg-amber-400/15 border border-amber-400/30 flex items-center justify-center shrink-0",children:(0,h.jsx)("span",{className:"text-amber-400 font-bold text-sm",children:(null===(t=e.partner_name)||void 0===t?void 0:t.charAt(0))||"?"})}),(0,h.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,h.jsxs)("div",{className:"flex items-center justify-between",children:[(0,h.jsx)("p",{className:"text-white text-sm font-medium truncate",children:e.partner_name||"User"}),e.unread>0&&(0,h.jsx)("span",{className:"bg-[#D4AF37] text-black text-[10px] font-bold rounded-full w-5 h-5 flex items-center justify-center shrink-0",children:e.unread})]}),(0,h.jsx)("p",{className:"text-xs text-slate-500 truncate",children:(null===(r=e.last_message)||void 0===r?void 0:r.text)||""})]})]},e.partner_id)})]})}function p(e){let{conversation:t,userId:s}=e;const[r,l]=(0,a.useState)([]),[o,f]=(0,a.useState)(""),[p,b]=(0,a.useState)(!1),[v,g]=(0,a.useState)(!0),j=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(!t)return;const e=async()=>{try{const{data:e}=await n.A.get("".concat(u.A,"/messages/thread/").concat(t.partner_id));l(e.messages||[])}catch(e){console.error(e)}g(!1)};e();const s=setInterval(e,5e3);return()=>clearInterval(s)},[t]),(0,a.useEffect)(()=>{var e;null===(e=j.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})},[r]);return t?(0,h.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,h.jsx)("div",{className:"p-4 border-b border-white/[0.05]",children:(0,h.jsx)("p",{className:"text-white font-heading font-medium",children:t.partner_name||"User"})}),(0,h.jsxs)("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 max-h-[400px]",children:[v&&(0,h.jsx)(d.A,{className:"w-5 h-5 text-amber-400 animate-spin mx-auto"}),r.map(e=>(0,h.jsx)("div",{className:"flex ".concat(e.from_id===s?"justify-end":"justify-start"),children:(0,h.jsxs)("div",{className:"max-w-[70%] px-4 py-2 rounded-2xl text-sm ".concat(e.from_id===s?"bg-amber-400/10 text-amber-100 rounded-br-md":"bg-white/5 text-slate-300 rounded-bl-md"),children:[e.text,(0,h.jsx)("p",{className:"text-[10px] text-slate-600 mt-1",children:new Date(e.created_at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})},e.id)),(0,h.jsx)("div",{ref:j})]}),(0,h.jsxs)("form",{onSubmit:async e=>{if(e.preventDefault(),o.trim()){b(!0);try{const{data:e}=await n.A.post("".concat(u.A,"/messages/send"),{to_profile_id:t.to_profile_id||"",text:o.trim()});l(t=>[...t,e]),f("")}catch(e){console.error(e),x.oR.error("Could not send message")}b(!1)}},className:"p-4 border-t border-white/[0.05] flex gap-2",children:[(0,h.jsx)(c.p,{value:o,onChange:e=>f(e.target.value),placeholder:"Type a message...",className:"bg-black/40 border-white/10 text-white rounded-xl focus:ring-amber-400/50","data-testid":"msg-input"}),(0,h.jsx)(i.$,{type:"submit",disabled:p||!o.trim(),className:"bg-[#D4AF37] text-black rounded-xl px-4 hover:bg-[#d4b04e]",children:p?(0,h.jsx)(d.A,{className:"w-4 h-4 animate-spin"}):(0,h.jsx)(m.A,{className:"w-4 h-4"})})]})]}):(0,h.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-600 text-sm",children:"Select a conversation"})}function b(){const{user:e}=(0,l.A)(),[t,s]=(0,a.useState)([]),[c,o]=(0,a.useState)(null),[m,x]=(0,a.useState)(!0);return(0,a.useEffect)(()=>
1{if(!e)return;(async()=>{try{const{data:e}=await n.A.get("".concat(u.A,"/messages/conversations"));s(e.conversations||[])}catch(e){console.error(e)}x(!1)})()},[e]),e?(0,h.jsx)("div",{className:"min-h-screen bg-[#0A0A0E] pt-20 pb-16 px-4","data-testid":"messages-page",children:(0,h.jsxs)("div",{className:"max-w-4xl mx-auto",children:[(0,h.jsxs)("div",{className:"mb-6",children:[(0,h.jsx)("p",{className:"text-xs tracking-[0.2em] uppercase text-amber-400 font-semibold mb-1",children:"Messages"}),(0,h.jsx)("h1",{className:"font-heading text-2xl text-white font-semibold",children:"Conversations"})]}),(0,h.jsxs)("div",{className:"glass-card overflow-hidden flex",style:{minHeight:"500px"},children:[(0,h.jsx)("div",{className:"w-80 border-r border-white/[0.05] p-3 overflow-y-auto",children:m?(0,h.jsx)(d.A,{className:"w-5 h-5 text-amber-400 animate-spin mx-auto mt-8"}):(0,h.jsx)(f,{conversations:t,selected:c,onSelect:o})}),(0,h.jsx)(p,{conversation:c,userId:null===e||void 0===e?void 0:e.id})]})]})}):(0,h.jsx)("div",{className:"min-h-screen bg-[#0A0A0E] flex items-center justify-center pt-16",children:(0,h.jsxs)("div",{className:"text-center",children:[(0,h.jsx)("p",{className:"text-slate-400 mb-4",children:"Sign in to view messages"}),(0,h.jsx)(r.N_,{to:"/authorize",children:(0,h.jsx)(i.$,{className:"bg-[#D4AF37] text-black rounded-full px-6 font-semibold hover:bg-[#d4b04e]",children:"Sign In"})})]})})}}}]); 2//# sourceMappingURL=816.0bfae544.chunk.js.map
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.