PageSourceSearch

https://drive4usyd.manus.space/assets/DriverChat-DrfqsB1b.js

js drive4usyd.manus.space collected 2026-10-03 05:03:13 UTC 6,699 bytes, 1 lines download raw bytes

1import{r as i,t as c,j as e,o as l,b as p,K as g,O as u,c as C,B as D,k as N,q as y,H as b}from"./index-U8D282DB.js";import{B as w}from"./badge-BmpMbrZ9.js";import{I}from"./input-DFtjl8GZ.js";import{S}from"./send-BoC6s2a6.js";import"./useComposition-DGvQVl2f.js";function R(){const[s,o]=i.useState(null),[t,m]=i.useState(""),x=i.useRef(null),h=c.useUtils(),{data:d=[],isLoading:f}=c.drivers.conversations.useQuery(),{data:v=[]}=c.drivers.driverChat.useQuery({driverId:s},{enabled:!!s,refetchInterval:1e4}),n=c.drivers.adminReply.useMutation({onSuccess:()=>{m(""),h.drivers.driverChat.invalidate(),h.drivers.conversations.invalidate()}});i.useEffect(()=>{x.current?.scrollIntoView({behavior:"smooth"})},[v]);const j=d.find(a=>a.driverId===s);return e.jsxs("div",{"data-loc":"client/src/pages/admin/DriverChat.tsx:36",className:"p-6",children:[e.jsxs("h1",{"data-loc":"client/src/pages/admin/DriverChat.tsx:37",className:"text-2xl font-bold mb-6 flex items-center gap-2",children:[e.jsx(l,{"data-loc":"client/src/pages/admin/DriverChat.tsx:38",className:"h-6 w-6"}),"Driver Messages"]}),e.jsxs("div",{"data-loc":"client/src/pages/admin/DriverChat.tsx:42",className:"grid grid-cols-1 md:grid-cols-3 gap-6 h-[calc(100vh-200px)]",children:[e.jsxs(p,{"data-loc":"client/src/pages/admin/DriverChat.tsx:44",className:"md:col-span-1 overflow-hidden flex flex-col",children:[e.jsx(g,{"data-loc":"client/src/pages/admin/DriverChat.tsx:45",className:"pb-3",children:e.jsx(u,{"data-loc":"client/src/pages/admin/DriverChat.tsx:46",className:"text-sm font-medium text-muted-foreground",children:"Conversations"})}),e.jsx(C,{"data-loc":"client/src/pages/admin/DriverChat.tsx:48",className:"flex-1 overflow-y-auto p-0",children:f?e.jsx("div",{"data-loc":"client/src/pages/admin/DriverChat.tsx:50",className:"p-4 text-center text-muted-foreground",children:"Loading..."}):d.length===0?e.jsxs("div",{"data-loc":"client/src/pages/admin/DriverChat.tsx:52",className:"p-4 text-center text-muted-foreground",children:[e.jsx(l,{"data-loc":"client/src/pages/admin/DriverChat.tsx:53",className:"h-8 w-8 mx-auto mb-2 opacity-30"}),e.jsx("p",{"data-loc":"client/src/pages/admin/DriverChat.tsx:54",className:"text-sm",children:"No messages yet"})]}):e.jsx("div",{"data-loc":"client/src/pages/admin/DriverChat.tsx:57",className:"divide-y",children:d.map(a=>e.jsxs("button",{"data-loc":"client/src/pages/admin/DriverChat.tsx:59",onClick:()=>o(a.driverId),className:`w-full text-left p-4 hover:bg-muted/50 transition-colors ${s===a.driverId?"bg-muted":""}`,children:[e.jsxs("div",{"data-loc":"client/src/pages/admin/DriverChat.tsx:66",className:"flex items-center justify-between mb-1",children:[e.jsx("span",{"data-loc":"client/src/pages/admin/DriverChat.tsx:67",className:"font-medium text-sm",children:a.driverName}),a.unreadCount>0&&e.jsx(w,{"data-loc":"client/src/pages/admin/DriverChat.tsx:69",variant:"destructive",className:"text-xs px-1.5 py-0",children:a.unreadCount})]}),e.jsx("p",{"data-loc":"client/src/pages/admin/DriverChat.tsx:74",className:"text-xs text-muted-foreground truncate",children:a.lastMessage}),e.jsx("p",{"data-loc":"client/src/pages/admin/DriverChat.tsx:75",className:"text-xs text-muted-foreground mt-1",children:new Date(a.lastMessageAt).toLocaleString("en-AU",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit"})})]},a.driverId))})})]}),e.jsx(p,{"data-loc":"client/src/pages/admin/DriverChat.tsx:88",className:"md:col-span-2 overflow-hidden flex flex-col",children:s?e.jsxs(e.Fragment,{children:[e.jsx(g,{"data-loc":"client/src/pages/admin/DriverChat.tsx:98",className:"pb-3 border-b",children:e.jsxs("div",{"data-loc":"client/src/pages/admin/DriverChat.tsx:99",className:"flex items-center gap-2",children:[e.jsx(D,{"data-loc":"client/src/pages/admin/DriverChat.tsx:100",variant:"ghost",size:"icon",className:"md:hidden",onClick:()=>o(null),children:e.jsx(N,{"data-loc":"client/src/pages/admin/DriverChat.tsx:101",className:"h-4 w-4"})}),e.jsx(u,{"data-loc":"client/src/pages/admin/DriverChat.tsx:103",className:"text-base",children:j?.driverName||"Driver"})]})}),e.jsxs(C,{"data-loc":"client/src/pages/admin/DriverChat.tsx:106",className:"flex-1 overflow-y-auto p-4 space-y-3",children:[[...v].reverse().map(a=>{const r=a.sender==="admin";return e.jsx("div",{"data-loc":"client/src/pages/admin/DriverChat.tsx:110",className:`flex ${r?"justify-end":"justify-start"}`,children:e.jsxs("div",{"data-loc":"client/src/pages/admin/DriverChat.tsx:111",className:`max-w-[70%] rounded-2xl px-4 py-2.5 ${r?"bg-primary text-primary-foreground rounded-br-md":"bg-muted rounded-bl-md"}`,children:[e.jsxs("div",{"data-loc":"client/src/pages/admin/DriverChat.tsx:116",className:"flex items-center gap-1.5 mb-0.5",children:[r?e.jsx(y,{"data-loc":"client/src/pages/admin/DriverChat.tsx:118",className:"h-3 w-3 opacity-70"}):e.jsx(b,{"data-loc":"client/src/pages/admin/DriverChat.tsx:120",className:"h-3 w-3 opacity-70"}),e.jsx("span",{"data-loc":"client/src/pages/admin/DriverChat.tsx:122",className:"text-xs opacity-70",children:r?"Admin":"Driver"})]}),e.jsx("p",{"data-loc":"client/src/pages/admin/DriverChat.tsx:124",className:"text-sm",children:a.message}),e.jsx("p",{"data-loc":"client/src/pages/admin/DriverChat.tsx:125",className:`text-xs mt-1 ${r?"opacity-60":"text-muted-foreground"}
1`,children:new Date(a.createdAt).toLocaleString("en-AU",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit"})})]})},a.id)}),e.jsx("div",{"data-loc":"client/src/pages/admin/DriverChat.tsx:134",ref:x})]}),e.jsx("div",{"data-loc":"client/src/pages/admin/DriverChat.tsx:136",className:"p-4 border-t",children:e.jsxs("div",{"data-loc":"client/src/pages/admin/DriverChat.tsx:137",className:"flex gap-2",children:[e.jsx(I,{"data-loc":"client/src/pages/admin/DriverChat.tsx:138",value:t,onChange:a=>m(a.target.value),placeholder:"Type a reply...",onKeyDown:a=>{a.key==="Enter"&&t.trim()&&n.mutate({driverId:s,message:t.trim()})}}),e.jsx(D,{"data-loc":"client/src/pages/admin/DriverChat.tsx:148",onClick:()=>{t.trim()&&n.mutate({driverId:s,message:t.trim()})},disabled:!t.trim()||n.isPending,children:e.jsx(S,{"data-loc":"client/src/pages/admin/DriverChat.tsx:156",className:"h-4 w-4"})})]})})]}):e.jsx("div",{"data-loc":"client/src/pages/admin/DriverChat.tsx:90",className:"flex-1 flex items-center justify-center text-muted-foreground",children:e.jsxs("div",{"data-loc":"client/src/pages/admin/DriverChat.tsx:91",className:"text-center",children:[e.jsx(l,{"data-loc":"client/src/pages/admin/DriverChat.tsx:92",className:"h-12 w-12 mx-auto mb-3 opacity-20"}),e.jsx("p",{"data-loc":"client/src/pages/admin/DriverChat.tsx:93",children:"Select a conversation to view messages"})]})})})]})]})}export{R 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.