PageSourceSearch

https://smartmanageai.ai/assets/HelpWidget-Cuh4Pub3.js

js smartmanageai.ai collected 2026-10-05 15:06:05 UTC 19,346 bytes, 1 lines download raw bytes

1import{r,j as e}from"./vendor-react-DKbe1Umz.js";import{a as ie,y as re,u as H,A as le,E as ne,F as D,G as I,I as z,B as L,L as v,T as Y,q,o as O,l as de}from"./index-DZ74KeH3.js";import{u as E,a as V}from"./vendor-data-CjSe2wkl.js";import{u as ce}from"./use-ticket-stream-BkWK1cvl.js";import{bi as U,bg as oe,X as K,a8 as ue,c0 as N,E as me,Y as pe,cS as B,b8 as X,M as xe,ay as J,cr as he,cT as ge}from"./vendor-ui-DMaW9-Ov.js";import"./vendor-charts-DWX9qznF.js";import"./vendor-dates-5UNeOyFW.js";import"./vendor-forms-C2vWC2ab.js";const ye=[{value:"general",label:"General"},{value:"bids",label:"Bids"},{value:"payroll",label:"Payroll"},{value:"ai_estimator",label:"AI Estimator"},{value:"change_orders",label:"Change Orders"},{value:"documents",label:"Documents"}];function fe({slug:s,onBack:l}){const{data:d,isLoading:n}=E({queryKey:["/api/support/help/articles",s]});return e.jsxs("div",{className:"space-y-3","data-testid":"help-article-view",children:[e.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:underline",onClick:l,"data-testid":"button-help-article-back",children:"← Back to articles"}),n||!d?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(N,{className:"h-4 w-4 animate-spin"})," Loading…"]}):e.jsxs("article",{className:"prose prose-sm dark:prose-invert max-w-none",children:[e.jsx("h2",{className:"text-base font-semibold mb-2",children:d.title}),e.jsx("pre",{className:"whitespace-pre-wrap font-sans text-sm leading-relaxed bg-transparent p-0",children:d.body})]})]})}const Z={open:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",in_progress:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",waiting_on_customer:"bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-200",resolved:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",closed:"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400"},M={open:"Open",in_progress:"In Progress",waiting_on_customer:"Awaiting Reply",resolved:"Resolved",closed:"Closed"};function G({attachments:s}){return!s||s.length===0?null:e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2","data-testid":"attachment-list",children:s.map((l,d)=>e.jsxs("a",{href:`/api/support/attachments/download?key=${encodeURIComponent(l.objectKey)}`,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs bg-muted rounded px-2 py-1 hover:bg-muted/70 transition-colors","data-testid":`attachment-link-${d}`,children:[l.contentType.startsWith("image/")?e.jsx("img",{src:`/api/support/attachments/download?key=${encodeURIComponent(l.objectKey)}`,alt:l.fileName,className:"h-5 w-5 object-cover rounded"}):e.jsx(B,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-[120px] truncate",children:l.fileName}),e.jsx(ge,{className:"h-3 w-3 text-muted-foreground"})]},d))})}function ee({onFiles:s,disabled:l}){const d=r.useRef(null);return e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:d,type:"file",multiple:!0,accept:"image/*,.pdf,.doc,.docx,.xls,.xlsx,.txt",className:"hidden",onChange:n=>{const c=Array.from(n.target.files??[]);c.length&&s(c),n.target.value=""}}),e.jsx(L,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-muted-foreground",onClick:()=>{var n;return(n=d.current)==null?void 0:n.click()},disabled:l,"data-testid":"button-attach-file",title:"Attach file",children:e.jsx(B,{className:"h-4 w-4"})})]})}function je({ticket:s,onBack:l,currentUserId:d}){var C;const{toast:n}=H(),[c,y]=r.useState(""),[i,h]=r.useState([]),g=E({queryKey:["/api/support/my-tickets",s.id,"replies"],queryFn:()=>O("GET",`/api/support/my-tickets/${s.id}/replies`).then(a=>a.json())}),{newReplyArrived:u,clearNewReplyFlag:w,usingPolling:Q}=ce(s.id,!1,{onNewReply:()=>{n({title:"New reply received",description:"The support team has replied to your ticket."})}});r.useEffect(()=>{u&&w()},[u,w]);const p=V({mutationFn:async()=>{var x;const o=await(await O("POST",`/api/support/my-tickets/${s.id}/replies`,{body:c})).json();if(i.length>0&&((x=o.reply)!=null&&x.id)){const T=new FormData;
1i.forEach(b=>T.append("files",b)),await fetch(`/api/support/tickets/${s.id}/replies/${o.reply.id}/attachments`,{method:"POST",body:T,credentials:"include"})}return o},onSuccess:()=>{y(""),h([]),q.invalidateQueries({queryKey:["/api/support/my-tickets",s.id,"replies"]}),q.invalidateQueries({queryKey:["/api/support/my-tickets"]}),n({title:"Reply sent",description:"Your reply has been sent to the support team."})},onError:a=>{n({title:"Could not send reply",description:a.message||"Please try again.",variant:"destructive"})}}),k=((C=g.data)==null?void 0:C.replies)??[],j=s.status==="resolved"||s.status==="closed",S=s.attachments??[];return e.jsxs("div",{className:"space-y-3","data-testid":"ticket-thread-view",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",className:"text-xs text-muted-foreground hover:underline inline-flex items-center gap-1",onClick:l,"data-testid":"button-ticket-back",children:[e.jsx(he,{className:"h-3 w-3"})," Back to my tickets"]}),Q&&e.jsx("span",{className:"text-[10px] text-muted-foreground","data-testid":"text-polling-fallback",children:"Refreshing every 30s"})]}),e.jsxs("div",{className:"rounded-md border border-border p-3 space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"text-sm font-semibold leading-snug",children:s.subject}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium shrink-0 ${Z[s.status]}`,"data-testid":"text-ticket-status",children:M[s.status]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(J,{className:"h-3 w-3"}),new Date(s.createdAt).toLocaleDateString()]}),e.jsx("div",{className:"text-sm text-foreground whitespace-pre-wrap mt-2 pt-2 border-t border-border",children:s.body}),e.jsx(G,{attachments:S})]}),g.isLoading?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(N,{className:"h-4 w-4 animate-spin"})," Loading replies…"]}):k.length===0?e.jsx("div",{className:"text-xs text-muted-foreground text-center py-3",children:"No replies yet — we'll respond within your plan's SLA window."}):e.jsx("div",{className:"space-y-2","data-testid":"ticket-replies-list",children:k.map(a=>{const o=a.authorId===d,x=a.attachments??[];return e.jsxs("div",{className:`rounded-md p-3 text-sm ${o?"bg-primary/10 ml-4":"bg-muted mr-4"}`,"data-testid":`ticket-reply-${a.id}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium text-xs",children:o?"You":"Support Team"}),!o&&e.jsx(de,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4",children:"Support"}),e.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:new Date(a.createdAt).toLocaleString()})]}),e.jsx("div",{className:"whitespace-pre-wrap",children:a.body}),e.jsx(G,{attachments:x})]},a.id)})}),!j&&e.jsxs("form",{onSubmit:a=>{a.preventDefault(),c.trim()&&p.mutate()},className:"space-y-2 pt-2 border-t border-border",children:[e.jsx(v,{htmlFor:"reply-body",className:"text-xs",children:"Reply to Support Team"}),e.jsx(Y,{id:"reply-body",value:c,onChange:a=>y(a.target.value),placeholder:"Type your reply…",rows:3,required:!0,minLength:1,"data-testid":"input-ticket-reply-body"}),i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1","data-testid":"pending-files-list",children:i.map((a,o)=>e.jsxs("div",{className:"inline-flex items-center gap-1 text-xs bg-muted rounded px-2 py-1",children:[e.jsx(B,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-[100px] truncate",children:a.name}),e.jsx("button",{type:"button",onClick:()=>h(x=>x.filter((T,b)=>b!==o)),className:"text-muted-foreground hover:text-foreground",children:e.jsx(K,{className:"h-3 w-3"})})]},o))}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(ee,{onFiles:a=>h(o=>[...o,...a]),disabled:p.isPending}),e.jsx(L,{type:"submit",size:"sm",disabled:p.isPending||!c.trim(),className:"flex-1","data-testid":"button-ticket-reply-submit",children:p.isPending?e.jsx(N,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"h-3 w-3 mr-1"})," Send Reply"]})})]})]}),j&&e.jsxs("div",{className:"text-xs text-center text-muted-foreground py-2",children:["This ticket is ",M[s.status].toLowerCase(),". Open a new ticket if you need further help."]})]})}function be({currentUserId:s}){var y;const[l,d]=r.useState(null),n=E({queryKey:["/api/support/my-tickets"],queryFn:()=>O("GET","/api/support/my-tickets").then(i=>i.json())}),c=((y=n.data)==null?void 0:y.tickets)??[];return l?e.jsx(je,{ticket:l,onBack:()=>d(null),currentUserId:s}):n.isLoading?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-4",children:[e.jsx(N,{className:"h-4 w-4 animate-spin"})," Loading your tickets…"]}):c.length===0?e.jsxs("div",{className:"text-center py-8 space-y-2","data-testid":"my-tickets-empty",children:[e.jsx(xe,{className:"h-8 w-8 text-muted-foreground mx-auto"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"No tickets yet."}),e.jsx("div",{className:"text-xs text-muted-foreground",children:'Submit a ticket via the "Contact us" tab.'})]}):e.jsx("div",{className:"space-y-2","data-testid":"my-tickets-list",children:c.map(i=>e.jsxs("button",{type:"button",onClick:()=>d(i),className:"w-full text-left rounded-md border border-border p-3 hover:bg-muted/50 transition-colors space-y-1","data-testid":`ticket-item-${i.id}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"text-sm font-medium leading-snug line-clamp-1",children:i.subject}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium shrink-0 ${Z[i.status]}`,children:M[i.status]})]}),e.jsx("div",{className:"text-xs text-muted-foreground line-clamp-2",children:i.body}),e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(J,{className:"h-3 w-3"}),new Date(i.createdAt).toLocaleDateString()]})]},i.id))})}function Fe(){var W;const[s,l]=r.useState(!1),[d,n]=r.useState("articles"),[c,y]=r.useState(""),[i,h]=r.useState(null),[g]=ie(),{user:u}=re(),{toast:w}=H(),p=E({queryKey:["/api/support/help/articles",{q:c,route:g}],enabled:s}),k=r.useMemo(()=>{var f;const t=((f=p.data)==null?void 0:f.articles)??[],m=t.filter(R=>R.routes.some($=>g.startsWith($)));return m.length>0?m.slice(0,5):t.slice(0,5)},[p.data,g]),j=((W=p.data)==null?void 0:W.articles)??[],[S,C]=r.useState(""),[a,o]=r.useState(""),[x,T]=r.useState("general"),[b,te]=r.useState("normal"),[A,_]=r.useState([]),[se,F]=r.useState(!1),[ve,ae]=r.useState(null),P=V({mutationFn:async()=>{const m=await(await O("POST","/api/support/tickets",{subject:S,body:a,priority:b,category:x,submitterEmail:u==null?void 0:u.email,submitterName:[u==null?void 0:u.firstName,u==null?void 0:u.lastName].filter(
1Boolean).join(" ")||void 0,route:g,userAgent:typeof navigator<"u"?navigator.userAgent:void 0,metadata:{url:typeof window<"u"?window.location.href:void 0}})).json();if(A.length>0&&m.id){const f=new FormData;A.forEach(R=>f.append("files",R)),await fetch(`/api/support/tickets/${m.id}/attachments`,{method:"POST",body:f,credentials:"include"}).catch(()=>{})}return m},onSuccess:t=>{F(!0),ae(t.id??null),C(""),o(""),_([]),q.invalidateQueries({queryKey:["/api/support/tickets"]}),q.invalidateQueries({queryKey:["/api/support/my-tickets"]}),w({title:"Ticket submitted",description:"Our team will respond per your plan SLA."})},onError:t=>{w({title:"Could not submit ticket",description:t.message||"Please try again.",variant:"destructive"})}});return r.useEffect(()=>{s||(h(null),F(!1))},[s]),u?e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>l(t=>!t),className:"inline-flex items-center gap-2 rounded-full bg-primary text-primary-foreground shadow-lg px-4 py-3 hover:bg-primary/90","aria-label":"Open help","data-testid":"button-open-help-widget",children:[e.jsx(U,{className:"h-5 w-5"}),e.jsx("span",{className:"text-sm font-medium hidden sm:inline",children:"Help"})]}),s&&e.jsxs("div",{className:"fixed bottom-20 right-5 z-50 w-[380px] max-w-[calc(100vw-1.5rem)] rounded-lg border border-border bg-card text-card-foreground shadow-2xl","data-testid":"help-widget-panel",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm font-semibold",children:"Help & Support"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("a",{href:"/status",target:"_blank",rel:"noreferrer",className:"text-xs text-muted-foreground hover:underline inline-flex items-center gap-1","data-testid":"link-help-status",children:[e.jsx(oe,{className:"h-3 w-3"})," Status"]}),e.jsx("button",{type:"button",onClick:()=>l(!1),className:"p-1 text-muted-foreground hover:text-foreground","aria-label":"Close help","data-testid":"button-close-help-widget",children:e.jsx(K,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"p-3 max-h-[70vh] overflow-y-auto",children:e.jsxs(le,{value:d,onValueChange:n,children:[e.jsxs(ne,{className:"grid grid-cols-3 w-full",children:[e.jsx(D,{value:"articles","data-testid":"tab-help-articles",children:"Articles"}),e.jsx(D,{value:"ticket","data-testid":"tab-help-ticket",children:"Contact us"}),e.jsx(D,{value:"my-tickets","data-testid":"tab-help-my-tickets",children:"My Tickets"})]}),e.jsx(I,{value:"articles",className:"space-y-3 mt-3",children:i?e.jsx(fe,{slug:i,onBack:()=>h(null)}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx(ue,{className:"absolute left-2 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(z,{value:c,onChange:t=>y(t.target.value),placeholder:"Search the help center",className:"pl-8","data-testid":"input-help-search"})]}),!c&&k.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs uppercase tracking-wide text-muted-foreground mb-2",children:"For this page"}),e.jsx("ul",{className:"space-y-1",children:k.map(t=>e.jsx("li",{children:e.jsx("button",{type:"button",onClick:()=>h(t.slug),className:"text-left text-sm hover:underline","data-testid":`link-help-contextual-${t.slug}`,children:t.title})},t.slug))})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs uppercase tracking-wide text-muted-foreground mb-2",children:c?`Results (${j.length})`:"All articles"}),p.isLoading?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(N,{className:"h-4 w-4 animate-spin"})," Loading…"]}):j.length===0?e.jsx("div",{className:"text-sm text-muted-foreground",children:"No articles found."}):e.jsx("ul",{className:"space-y-2",children:j.slice(0,30).map(t=>e.jsx("li",{className:"border-b border-border pb-2 last:border-0",children:e.jsxs("button",{type:"button",onClick:()=>h(t.slug),className:"text-left w-full","data-testid":`link-help-article-${t.slug}`,children:[e.jsx("div",{className:"text-sm font-medium",children:t.title}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.module})]})},t.slug))})]}),e.jsxs("a",{href:"/help",className:"text-xs text-primary hover:underline inline-flex items-center gap-1","data-testid":"link-help-open-center",children:["Open the full help center ",e.jsx(me,{className:"h-3 w-3"})]})]})}),e.jsx(I,{value:"ticket",className:"mt-3 space-y-3",children:se?e.jsxs("div",{className:"text-center py-6 space-y-2","data-testid":"help-ticket-success",children:[e.jsx(pe,{className:"h-8 w-8 text-green-500 mx-auto"}),e.jsx("div",{className:"text-sm font-medium",children:"We've got your ticket."}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["You'll get an email reply within your plan's SLA window."," ",e.jsx("a",{href:"/sla",target:"_blank",rel:"noreferrer",className:"underline",children:"See SLA"})]}),e.jsxs("div",{className:"flex gap-2 justify-center flex-wrap",children:[e.jsx(L,{size:"sm",variant:"outline",onClick:()=>F(!1),"data-testid":"button-help-ticket-new",children:"Submit another ticket"}),e.jsx(L,{size:"sm",variant:"outline",onClick:()=>{n("my-tickets"),F(!1)},"data-testid":"button-help-view-tickets",children:"View my tickets"})]})]}):e.jsxs("form",{onSubmit:t=>{t.preventDefault(),!(!S.trim()||!a.trim())&&P.mutate()},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(v,{htmlFor:"help-category",className:"text-xs",children:"Category"}),e.jsx("select",{id:"help-category",value:x,onChange:t=>T(t.target.value),className:"w-full rounded-md border border-input bg-background text-sm px-2 py-1.5","data-testid":"select-help-ticket-category",children:ye.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))})]}),e.jsxs("div",{children:[e.jsx(v,{htmlFor:"help-subject",className:"text-xs",children:"Subject"}),e.jsx(z,{id:"help-subject",value:S,onChange:t=>C(t.target.value),placeholder:"Briefly describe the issue",required:!0,minLength:3,"data-testid":"input-help-ticket-subject"})]}),e.jsxs("div",{children:[e.jsx(v,{htmlFor:"help-body",className:"text-xs",children:"Details"}),e.jsx(Y,{id:"help-body",value:a,onChange:t=>o(t.target.value),placeholder:"What happened? What did you expect?",rows:4,required:!0,minLength:5,"data-testid":"input-help-ticket-body"})]}),e.jsxs("div",{children:[e.jsx(v,{htmlFor:"help-priority",className:"text-xs",children:"Priority"}),e.jsxs("select",{id:"help-priority",value:b,onChange:t=>te(t.target.value),className:"w-full rounded-md border border-input bg-background text-sm px-2 py-1.5","data-testid":"select-help-ticket-priority",children:[e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"normal",children:"Normal"}),e.jsx("option",{value:"high",children:"High"}),e.jsx("option",{value:"urgent",children:"Urgent"})]})]}),e.jsxs("div",{children:[e.jsx(v,{className:"text-xs",children:"Attachments (optional)"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(ee,{onFiles:t=>_(m=>[...m,...t]),disabled:P.isPending}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Images, PDFs, Office docs up to 25 MB each"})]}),A.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2","data-testid":"ticket-pending-files",children:A.map((t,m)=>e.jsxs("div",{className:"inline-flex items-center gap-1 text-xs bg-muted rounded px-2 py-1",children:[e.jsx(B,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-[100px] truncate",children:t.name}),e.jsx("button",{type:"button",onClick:()=>_(f=>f.filter((R,$)=>$!==m)),className:"text-muted-foreground hover:text-foreground",children:e.jsx(K,{className:"h-3 w-3"})})]},m))})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["We'll attach this page (",g,"), your user, and your organization automatically."]}),e.jsx(L,{type:"submit",disabled:P.isPending,className:"w-full","data-testid":"button-help-ticket-submit",children:P.isPending?e.jsx(N,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"h-4 w-4 mr-2"})," Submit ticket"]})})]})}),e.jsx(I,{value:"my-tickets",className:"mt-3",children:e.jsx(be,{currentUserId:u.id})})]})})]})]}):null}export{Fe 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.