1import{r,a2 as f,F as j,ae as g,j as e,ai as v}from"./vendor-react-P6J-1gE6.js";import{u as w,d as k,s as a}from"./index-rf53WPCQ.js";import{L as o}from"./vendor-router-CavC29gp.js";import"./vendor-editor-C-BaHFr1.js";import"./vendor-pdf-BV9V_-5J.js";import"./vendor-supabase-BZ0N5lZN.js";import"./vendor-motion-Cl_6XfjD.js";function q(){const{t}=w("admin"),{formatDateTime:n}=k(),[i,c]=r.useState({newTickets:0,awaitingShipment:0,overdueTickets:0}),[l,d]=r.useState([]);r.useEffect(()=>{(async()=>{const m=new Date(Date.now()-864e5).toISOString(),[x,p,h,b]=await Promise.all([a.from("contact_messages").select("id",{count:"exact",head:!0}).eq("status","new"),a.from("orders").select("id",{count:"exact",head:!0}).in("status",["paid","confirmed"]),a.from("contact_messages").select("id",{count:"exact",head:!0}).eq("status","new").lt("created_at",m),a.from("contact_messages").select("id, subject, email, created_at, status").order("created_at",{ascending:!1}).limit(6)]);c({newTickets:x.count||0,awaitingShipment:p.count||0,overdueTickets:h.count||0}),d(b.data||[])})()},[]);const u=[{key:"newTickets",value:i.newTickets,icon:f,accent:"bg-sky-50 text-sky-700",link:"/support/contact-messages"},{key:"awaitingShipment",value:i.awaitingShipment,icon:j,accent:"bg-amber-50 text-amber-700",link:"/support/orders"},{key:"overdueTickets",value:i.overdueTickets,icon:g,accent:"bg-rose-50 text-rose-700",link:"/support/contact-messages"}];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold text-slate-900",children:t("supportDashboard.title",{defaultValue:"Support desk"})}),e.jsx("p",{className:"text-sm text-slate-500",children:t("supportDashboard.subtitle",{defaultValue:"Track open conversations and unblock deliveries for customers."})})]}),e.jsxs(o,{to:"/support/knowledge",className:"inline-flex items-center gap-2 px-4 py-2.5 rounded-xl border border-slate-300 text-sm font-medium text-slate-700 hover:bg-slate-50 transition-colors",children:[e.jsx(v,{className:"w-4 h-4"}),t("supportDashboard.openPlaybook",{defaultValue:"Open playbook"})]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:u.map(s=>e.jsx(o,{to:s.link,className:"bg-white rounded-xl border border-slate-200 p-5 hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500 uppercase tracking-wide",children:t(`supportDashboard.cards.${s.key}`,{defaultValue:s.key})}),e.jsx("p",{className:"text-2xl font-semibold text-slate-900 mt-1",children:s.value})]}),e.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${s.accent}`,children:e.jsx(s.icon,{className:"w-4.5 h-4.5"})})]})},s.key))}),e.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-5 border-b border-slate-200",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-medium text-slate-900",children:t("supportDashboard.queue",{defaultValue:"Unresolved conversations"})}),e.jsx("p",{className:"text-sm text-slate-500",children:t("supportDashboard.queueHint",{defaultValue:"Oldest customer messages requiring action."})})]}),e.jsx(o,{to:"/support/contact-messages",className:"text-sm text-mc-blue-600 hover:underline",children:t("supportDashboard.viewInbox",{defaultValue:"Open inbox"})})]}),l.length===0?e.jsx("div",{className:"p-10 text-center text-slate-500 text-sm",children:t("supportDashboard.empty",{defaultValue:"Great newsâno unread tickets right now."})}):e.jsx("div",{className:"divide-y divide-slate-100",children:l.map(s=>e.jsxs("div",{className:"px-5 py-3 flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:s.subject||t("supportDashboard.noSubject",{defaultValue:"No subject"})}),e.jsx("p",{className:"text-xs text-slate-500",children:s.email})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-xs text-slate-400 uppercase tracking-wide",children:t(`supportDashboard.status.${s.status}`,{defaultValue:s.status})}),e.jsx("p",{className:"text-xs text-slate-500",children:n(s.created_at,{dateStyle:"medium",timeStyle:"short"})})]})]},s.id))})]})]})}export{q 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.