PageSourceSearch

https://getcookies.co/assets/SuperAdminSupportTicketsPage-CRo3aR9c.js

js getcookies.co collected 2026-10-08 23:31:01 UTC 13,363 bytes, 1 lines download raw bytes

1import{u as $,r as l,t as d,j as e,bN as P,L as O,q as I,P as U,I as D}from"./index-Coid6E-g.js";import{F as v}from"./TicketIcon-n17-1PVS.js";import{F as M}from"./ClockIcon-D1saSO4I.js";import{F as q}from"./ExclamationCircleIcon-2TXZXW8K.js";import{F as B}from"./FunnelIcon-CkuO-j5m.js";import{F as E}from"./PaperAirplaneIcon-qKOBrDca.js";const W=[{value:"all",label:"All Statuses"},{value:"open",label:"Open"},{value:"in_progress",label:"In Progress"},{value:"waiting_on_customer",label:"Waiting on Customer"},{value:"resolved",label:"Resolved"},{value:"closed",label:"Closed"}],z=[{value:"all",label:"All Categories"},{value:"technical",label:"Technical Issue"},{value:"billing",label:"Billing"},{value:"account",label:"Account"},{value:"integration",label:"Integration"},{value:"compliance",label:"Compliance"},{value:"feature_request",label:"Feature Request"},{value:"bug_report",label:"Bug Report"},{value:"general",label:"General"}],N={low:"bg-gray-100 text-gray-800",normal:"bg-blue-100 text-blue-800",high:"bg-orange-100 text-orange-800",urgent:"bg-red-100 text-red-800"},G={open:"bg-blue-100 text-blue-800",in_progress:"bg-yellow-100 text-yellow-800",waiting_on_customer:"bg-orange-100 text-orange-800",resolved:"bg-green-100 text-green-800",closed:"bg-gray-100 text-gray-800"},H=t=>({open:"Open",in_progress:"In Progress",waiting_on_customer:"Waiting on Customer",resolved:"Resolved",closed:"Closed"})[t]||t;function Z(){const{t}=$(),[i,w]=l.useState([]),[S,p]=l.useState(!0),[u,k]=l.useState(""),[n,C]=l.useState("all"),[o,T]=l.useState("all"),[a,c]=l.useState(null),[x,g]=l.useState(""),[h,y]=l.useState(!1),[b,j]=l.useState(!1);l.useEffect(()=>{m()},[n,o]);const m=async()=>{try{p(!0);const s={};n!=="all"&&(s.status=n),o!=="all"&&(s.category=o);const r=await d.getSupportTickets(s);w(r.items||[])}catch(s){console.error("Failed to load tickets:",s)}finally{p(!1)}},F=async()=>{if(!(!a||!x.trim())){y(!0);try{await d.replyToSupportTicket(a.id,x);const s=await d.getSupportTicket(a.id);c(s),g(""),m()}catch(s){console.error("Failed to send reply:",s)}finally{y(!1)}}},R=async s=>{if(a){j(!0);try{await d.updateSupportTicketStatus(a.id,s);const r=await d.getSupportTicket(a.id);c(r),m()}catch(r){console.error("Failed to update status:",r)}finally{j(!1)}}},f=i.filter(s=>{if(!u)return!0;const r=u.toLowerCase();return s.ticketNumber.toLowerCase().includes(r)||s.email.toLowerCase().includes(r)||s.subject.toLowerCase().includes(r)||(s.name?.toLowerCase().includes(r)??!1)}),_=i.filter(s=>s.status==="open").length,L=i.filter(s=>s.status==="in_progress").length,A=i.filter(s=>s.priority==="urgent"&&s.status!=="closed"&&s.status!=="resolved").length;return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx(P,{}),e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:[e.jsxs("div",{className:"flex justify-between items-start mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Support Tickets"}),e.jsx("p",{className:"text-gray-600",children:"View and respond to customer support requests"})]}),e.jsx(O,{to:"/super-admin",className:"text-primary-600 hover:text-primary-700",children:"Back to Dashboard"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-6",children:[e.jsx("div",{className:"bg-white p-4 rounded-lg shadow border-l-4 border-blue-500",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(v,{className:"h-8 w-8 text-blue-500 mr-3"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold text-gray-900",children:_}),e.jsx("p",{className:"text-sm text-gray-500",children:"Open Tickets"})]})]})}),e.jsx("div",{className:"bg-white p-4 rounded-lg shadow border-l-4 border-yellow-500",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(M,{className:"h-8 w-8 text-yellow-500 mr-3"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold text-gray-900",children:L}),e.jsx("p",{className:"text-sm text-gray-500",children:"In Progress"})]})]})}),e.jsx("div",{className:"bg-white p-4 rounded-lg shadow border-l-4 border-red-500",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(q,{className:"h-8 w-8 text-red-500 mr-3"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold text-gray-900",children:A}),e.jsx("p",{className:"text-sm text-gray-500",children:"Urgent"})]})]})}),e.jsx("div",{className:"bg-white p-4 rounded-lg shadow border-l-4 border-green-500",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(I,{className:"h-8 w-8 text-green-500 mr-3"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold text-gray-900",children:i.length}),e.jsx("p",{className:"text-sm text-gray-500",children:"Total Tickets"})]})]})})]}),e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"bg-white p-4 rounded-lg shadow mb-4",children:e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsx("div",{className:"flex-1 min-w-[200px]",children:e.jsxs("div",{className:"relative",children:[e.jsx(U,{className:"h-5 w-5 absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"text",placeholder:t("superAdmin.supportTickets.searchPlaceholder"),value:u,onChange:s=>k(s.target.value),className:"w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:ring-primary-500 focus:border-primary-500"})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"h-5 w-5 text-gray-400"}),e.jsx("select",{value:n,onChange:s=>C(s.target.value),className:"px-3 py-2 border border-gray-300 rounded-lg focus:ring-primary-500 focus:border-primary-500",children:W.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))}),e.jsx("select",{value:o,onChange:s=>T(s.target.value),className:"px-3 py-2 border border-gray-300 rounded-lg focus:ring-primary-500 focus:border-primary-500",children:z.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))}),e.jsx("button",{onClick:m,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-lg",title:"Refresh","aria-label":"Refresh tickets",children:e.jsx(D,{className:"h-5 w-5","aria-hidden":"true"})})]})]})}),S?e.jsx("div",{className:"bg-white rounded-lg shadow overflow-hidden",children:Array.from({length:5}).map((s,r)=>e.jsxs("div",{className:"px-4 py-4 border-b border-gray-200 flex items-center gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"h-4 w-48 bg-gray-200 rounded animate-pulse"}),e.jsx("div",{className:"h-3 w-32 bg-gray-200 rounded animate-pulse mt-2"})]}),e.jsx("div",{className:"h-5 w-20 bg-gray-200 rounded-full animate-pulse"}),e.jsx("div",{className:"h-5 w-16 bg-gray-200 rounded-full animate-pulse"}),e.jsx("div",{className:"h-4 w-20 bg-gray-200 rounded animate-pulse"})]},r))}):f.length===0?e.jsxs("div",{className:"bg-white rounded-lg shadow p-12 text-center",children:[e.jsx(v,{className:"h-12 w-12 text-gray-400 mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"No tickets found"}),e.jsx("p",{className:"text-gray-500",children:"No support tickets match your filters."})]}):e.jsx("div",{className:"bg-white rounded-lg shadow overflow-hidden",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[e.jsx("thead",{className:"bg-gray-50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Ticket"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Status"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Priority"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Created"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200",children:f.map(s=>e.jsxs("tr",{onClick:()=>
1c(s),className:`cursor-pointer hover:bg-gray-50 transition-colors ${a?.id===s.id?"bg-primary-50":""}`,children:[e.jsxs("td",{className:"px-4 py-4",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900",children:s.subject}),e.jsxs("div",{className:"text-xs text-gray-500",children:["#",s.ticketNumber," · ",s.email]})]}),e.jsx("td",{className:"px-4 py-4",children:e.jsx("span",{className:`px-2 py-1 text-xs font-medium rounded-full ${G[s.status]||"bg-gray-100"}`,children:H(s.status)})}),e.jsx("td",{className:"px-4 py-4",children:e.jsx("span",{className:`px-2 py-1 text-xs font-medium rounded-full ${N[s.priority]||"bg-gray-100"}`,children:s.priority})}),e.jsx("td",{className:"px-4 py-4 text-sm text-gray-500",children:new Date(s.createdAt).toLocaleDateString()})]},s.id))})]})})]}),a&&e.jsxs("div",{className:"w-[480px] bg-white rounded-lg shadow",children:[e.jsxs("div",{className:"p-4 border-b border-gray-200",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900",children:a.subject}),e.jsxs("p",{className:"text-sm text-gray-500",children:["#",a.ticketNumber]})]}),e.jsx("button",{onClick:()=>c(null),className:"text-gray-400 hover:text-gray-600","aria-label":"Close ticket details",children:e.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-500",children:"Status:"}),e.jsxs("select",{value:a.status,onChange:s=>R(s.target.value),disabled:b,className:"px-2 py-1 text-sm border border-gray-300 rounded focus:ring-primary-500 focus:border-primary-500",children:[e.jsx("option",{value:"open",children:t("superAdmin.supportTickets.statusOpen")}),e.jsx("option",{value:"in_progress",children:t("superAdmin.supportTickets.statusInProgress")}),e.jsx("option",{value:"waiting_on_customer",children:t("superAdmin.supportTickets.statusWaitingOnCustomer")}),e.jsx("option",{value:"resolved",children:t("superAdmin.supportTickets.statusResolved")}),e.jsx("option",{value:"closed",children:t("superAdmin.supportTickets.statusClosed")})]}),b&&e.jsx("span",{className:"text-xs text-gray-500",children:"Updating..."})]})]}),e.jsxs("div",{className:"p-4 border-b border-gray-200 bg-gray-50",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"From:"}),e.jsx("p",{className:"font-medium",children:a.name||"Unknown"}),e.jsx("p",{className:"text-gray-600",children:a.email})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Category:"}),e.jsx("p",{className:"font-medium capitalize",children:a.category.replace("_"," ")})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Priority:"}),e.jsx("span",{className:`ml-2 px-2 py-0.5 text-xs font-medium rounded-full ${N[a.priority]}`,children:a.priority})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Created:"}),e.jsx("p",{className:"font-medium",children:new Date(a.createdAt).toLocaleString()})]})]}),a.url&&e.jsxs("div",{className:"mt-2",children:[e.jsx("span",{className:"text-gray-500 text-sm",children:"Related URL:"}),e.jsx("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",className:"text-primary-600 hover:underline text-sm block truncate",children:a.url})]})]}),e.jsxs("div",{className:"p-4 max-h-[400px] overflow-y-auto",children:[e.jsxs("div",{className:"mb-4 p-3 bg-blue-50 rounded-lg border border-blue-100",children:[e.jsx("p",{className:"text-xs text-blue-600 font-medium mb-1",children:"Original Message"}),e.jsx("p",{className:"text-sm text-gray-700 whitespace-pre-wrap",children:a.description})]}),a.messages?.map(s=>e.jsxs("div",{className:`mb-3 p-3 rounded-lg ${s.isStaff?"bg-primary-50 border border-primary-100 ml-4":"bg-gray-50 border border-gray-200 mr-4"}`,children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("span",{className:`text-xs font-medium ${s.isStaff?"text-primary-600":"text-gray-600"}`,children:s.isStaff?"Support Team":s.authorName||s.authorEmail}),e.jsx("span",{className:"text-xs text-gray-400",children:new Date(s.createdAt).toLocaleStr
1ing()})]}),e.jsx("p",{className:"text-sm text-gray-700 whitespace-pre-wrap",children:s.message})]},s.id))]}),a.status!=="closed"&&e.jsxs("div",{className:"p-4 border-t border-gray-200",children:[e.jsx("textarea",{value:x,onChange:s=>g(s.target.value),placeholder:t("superAdmin.supportTickets.replyPlaceholder"),rows:3,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-primary-500 focus:border-primary-500 text-sm"}),e.jsx("div",{className:"flex justify-end mt-2",children:e.jsx("button",{onClick:F,disabled:h||!x.trim(),className:"inline-flex items-center px-4 py-2 bg-primary-600 text-white text-sm font-medium rounded-lg hover:bg-primary-700 disabled:opacity-50 disabled:cursor-not-allowed",children:h?e.jsx(e.Fragment,{children:"Sending..."}):e.jsxs(e.Fragment,{children:[e.jsx(E,{className:"h-4 w-4 mr-2"}),"Send Reply"]})})})]})]})]})]})]})}export{Z 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.