PageSourceSearch

https://rubpage.com/assets/SupportChatPage-CAkRiF-Z.js

js rubpage.com collected 2026-10-02 19:38:20 UTC 10,931 bytes, 1 lines download raw bytes

1import{a as K,u as q,b as M,j as e}from"./vendor-query-nkyHp8gL.js";import{r as d}from"./vendor-react-BNT0nzvx.js";import{h as z,i as F,P as R,B as c,Y as A,n as N,s as l}from"./index-UlqsakHc.js";import{D as L}from"./DashboardLayout-BwqfxABs.js";import{T as I}from"./textarea-DFMIf01q.js";import{I as Q}from"./input-O_nO28FK.js";import{S as T,I as B}from"./scroll-area-CqytkIYZ.js";import{M as D}from"./shield-DMA6z9Kg.js";import{A as P}from"./arrow-left-BA21u0OK.js";import{S as $}from"./send-DDsiLTn-.js";import{C as U}from"./check-7w7r-eFz.js";import"./vendor-ui-DPPUfW-O.js";import"./vendor-charts-B_MCcq71.js";import"./vendor-supabase-BRDBMtg7.js";import"./input-otp-zCOwu37W.js";import"./shield-check-D_dnqQxv.js";import"./chevron-right-Cm0QdkHJ.js";import"./eye-Ca0Gb1H3.js";import"./mail-check-B9b1HxOk.js";import"./users-C1fVyj3Z.js";import"./newspaper-DDM9CgLF.js";import"./crown-DVNd9quJ.js";import"./target-nBqdJqET.js";import"./list-CEIXZF2y.js";import"./flag-CwDWn1bT.js";import"./index-BdQq_4o_.js";const y=a=>new Date(a).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),G=a=>{const o=Date.now()-new Date(a).getTime(),i=Math.floor(o/6e4);if(i<1)return"now";if(i<60)return`${i}m`;const t=Math.floor(i/60);return t<24?`${t}h`:`${Math.floor(t/24)}d`},je=()=>{const{user:a}=z(),{toast:o}=F(),i=K(),[t,m]=d.useState(null),[x,f]=d.useState(""),[w,u]=d.useState(!1),[v,k]=d.useState(""),[p,S]=d.useState(""),g=d.useRef(null),{data:j,isLoading:E}=q({queryKey:["user-support-tickets"],queryFn:async()=>{if(!a)return[];const{data:s,error:r}=await l.from("my_contact_messages").select("*").order("created_at",{ascending:!1}).limit(50);if(r)throw r;return s??[]},enabled:!!a,refetchInterval:6e4,refetchIntervalInBackground:!1}),n=j?.find(s=>s.id===t),{data:_}=q({queryKey:["user-ticket-replies",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await l.from("ticket_replies").select("*").eq("ticket_id",t).order("created_at",{ascending:!0});if(r)throw r;return s??[]},enabled:!!t,refetchInterval:3e4,refetchIntervalInBackground:!1});d.useEffect(()=>{if(g.current){const s=g.current.querySelector("[data-radix-scroll-area-viewport]");s&&(s.scrollTop=s.scrollHeight)}},[_]);const b=M({mutationFn:async()=>{if(!a)throw new Error("Not logged in");const{data:s}=await l.from("profiles").select("display_name, email").eq("id",a.id).single(),{data:r,error:C}=await l.from("contact_messages").insert({name:s?.display_name||a.user_metadata?.display_name||"User",email:s?.email||a.email||"",subject:v.trim()||null,message:p.trim(),user_id:a.id,status:"new",priority:"normal"}).select("id").single();if(C)throw C;return r},onSuccess:s=>{o({title:"Message sent",description:"We'll get back to you soon."}),k(""),S(""),u(!1),m(s.id),i.invalidateQueries({queryKey:["user-support-tickets"]})},onError:s=>o({title:"Failed",description:s.message,variant:"destructive"})}),h=M({mutationFn:async()=>{if(!t)return;const{error:s}=await l.from("ticket_replies").insert({ticket_id:t,author_type:"user",body:x.trim(),email_sent:!1});if(s)throw s;await l.from("contact_messages").update({status:"new"}).eq("id",t)},onSuccess:()=>{f(""),i.invalidateQueries({queryKey:["user-ticket-replies",t]}),i.invalidateQueries({queryKey:["user-support-tickets"]})},onError:s=>o({title:"Failed",description:s.message,variant:"destructive"})});return e.jsxs(L,{children:[e.jsx(R,{title:"Support — RubPage",noindex:!0}),e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(D,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground leading-tight",children:"Support"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Chat with our support team"})]})]}),e.jsxs(c,{size:"sm",className:"h-8 text-xs",onClick:()=>{u(!0),m(null)},children:[e.jsx(A,{className:"w-3.5 h-3.5 mr-1.5"}),"New Message"]})]}),e.jsxs("div",{className:"border border-border rounded-xl overflow-hidden bg-card flex h-[calc(100dvh-160px)] min-h-[400px]",children:[e.jsx("div",{className:`${n||w?"hidden md:flex":"flex"} flex-col w-full md:w-1/3 md:max-w-[320px] md:border-r border-border bg-card shrink-0`,children:e.jsx(T,{className:"flex-1",children:E?e.
1jsx("div",{className:"p-8 text-center",children:e.jsx(N,{className:"w-5 h-5 animate-spin text-muted-foreground mx-auto"})}):j?.length?e.jsx("div",{className:"divide-y divide-border",children:j.map(s=>e.jsxs("button",{onClick:()=>{m(s.id),u(!1),f("")},className:`w-full text-left px-3 py-2.5 hover:bg-accent/50 transition-colors ${t===s.id?"bg-accent":""}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.status==="replied"&&e.jsx("span",{className:"w-2 h-2 rounded-full bg-primary shrink-0"}),e.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:s.subject||"General inquiry"})]}),e.jsx("span",{className:"text-[11px] text-muted-foreground shrink-0 ml-2",children:G(s.created_at)})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.message}),e.jsx("div",{className:"flex items-center gap-2 mt-1.5",children:e.jsx("span",{className:`text-[10px] font-medium px-1.5 py-0.5 rounded ${s.status==="replied"?"bg-primary/10 text-primary":s.status==="closed"?"bg-muted text-muted-foreground":"bg-secondary text-secondary-foreground"}`,children:s.status==="replied"?"New reply":s.status==="closed"?"Closed":"Sent"})})]},s.id))}):e.jsxs("div",{className:"p-6 text-center",children:[e.jsx(B,{className:"w-8 h-8 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"No conversations yet"}),e.jsx("p",{className:"text-xs text-muted-foreground/70",children:"Start a new message to contact support"})]})})}),w?e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:[e.jsxs("div",{className:"px-4 py-3 bg-card border-b border-border flex items-center gap-3 shrink-0",children:[e.jsx(c,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 md:hidden",onClick:()=>u(!1),children:e.jsx(P,{className:"w-4 h-4"})}),e.jsx("p",{className:"text-sm font-semibold text-foreground",children:"New Message"})]}),e.jsxs("div",{className:"flex-1 p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Subject (optional)"}),e.jsx(Q,{value:v,onChange:s=>k(s.target.value.slice(0,200)),placeholder:"What's this about?",className:"text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Message"}),e.jsx(I,{value:p,onChange:s=>S(s.target.value.slice(0,2e3)),placeholder:"Describe your issue or question…",className:"min-h-[140px] text-sm resize-none"}),e.jsxs("p",{className:"text-[11px] text-muted-foreground mt-1",children:[p.length,"/2000"]})]})]}),e.jsx("div",{className:"border-t border-border p-4 bg-card shrink-0",children:e.jsxs(c,{className:"w-full h-9 text-sm",disabled:!p.trim()||b.isPending,onClick:()=>b.mutate(),children:[b.isPending?e.jsx(N,{className:"w-4 h-4 animate-spin mr-2"}):e.jsx($,{className:"w-4 h-4 mr-2"}),"Send Message"]})})]}):n?e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:[e.jsxs("div",{className:"px-4 py-3 bg-card border-b border-border flex items-center gap-3 shrink-0",children:[e.jsx(c,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 md:hidden",onClick:()=>m(null),children:e.jsx(P,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground truncate",children:n.subject||"General inquiry"}),e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Started ",y(n.created_at),n.status==="closed"&&" · Closed"]})]})]}),e.jsx(T,{className:"flex-1",ref:g,children:e.jsxs("div",{className:"p-3 sm:p-4 space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs("div",{className:"max-w-[85%]",children:[e.jsx("div",{className:"px-4 py-3 rounded-2xl rounded-br-md bg-primary text-primary-foreground",children:e.jsx("p",{className:"text-sm whitespace-pre-wrap leading-relaxed",children:n.message})}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1 text-right",children:y(n.created_at)})]})}),_?.filter(s=>s.author_type!=="note").map(s=>{const r=s.author_type==="user";return e.jsx("div",{className:`flex ${r?"justify-end":"justify-start"}`,children:e.jsxs("div",{className:"max-w-[85%]",children:[!r&&e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-[hsl(142,76%,36%)]/10 flex items-center justify-center",children:e.jsx(U,{className:"w-3 h-3 text-[hsl(142,76%,36%)]"})}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Eva, Support"})]}),e.jsx("div",{className:`px-4 py-3 rounded-2xl ${r?"rounded-br-md bg-primary text-primary-foreground":"rounded-bl-md bg-secondary/60 text-foreground border border-border"}`,children:e.jsx("p",{className:"text-sm whitespace-pre-wrap leading-relaxed",children:s.body})}),e.jsx("p",{className:`text-[10px] text-muted-foreground mt-1 ${r?"text-right":"text-left ml-8"}`,children:y(s.created_at)})]})},s.id)})]})}),n.status!=="closed"?e.jsx("div",{className:"border-t border-border p-3 bg-card shrink-0",children:e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx(I,{value:x,onChange:s=>
1f(s.target.value.slice(0,2e3)),placeholder:"Type a message…",className:"min-h-[44px] max-h-[120px] text-sm bg-background resize-none flex-1",onKeyDown:s=>{s.key==="Enter"&&!s.shiftKey&&x.trim()&&(s.preventDefault(),h.mutate())}}),e.jsx(c,{size:"icon",className:"h-[44px] w-[44px] shrink-0",disabled:!x.trim()||h.isPending,onClick:()=>h.mutate(),children:h.isPending?e.jsx(N,{className:"w-4 h-4 animate-spin"}):e.jsx($,{className:"w-4 h-4"})})]})}):e.jsx("div",{className:"border-t border-border p-4 bg-muted/30 text-center shrink-0",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"This conversation has been closed. Start a new message if you need further help."})})]}):e.jsx("div",{className:"flex-1 hidden md:flex items-center justify-center bg-muted/10",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-secondary/60 flex items-center justify-center mx-auto mb-4",children:e.jsx(D,{className:"w-6 h-6 text-muted-foreground/50"})}),e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Select a conversation"}),e.jsx("p",{className:"text-xs text-muted-foreground/60 mt-1",children:"Or start a new message"})]})})]})]})};export{je 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.