PageSourceSearch

https://smartdevops.ai/assets/Dashboard-ZEXQMu_e.js

js smartdevops.ai collected 2026-10-05 15:06:03 UTC 7,777 bytes, 11 lines download raw bytes

1import{F as f,ae as k,U as r,p as A,O as e,B as o,C as m}from"./index-IBHyG7M_.js";import{U as P}from"./users-BsNMWO3t.js";import{T as D}from"./trending-up-DAnGR7TJ.js";import{F as p}from"./file-text-CqvuMhVD.js";import{E as F}from"./eye-NfGCqBZa.js";import{R as T}from"./refresh-cw-BkPAHeqw.js";import{P as U}from"./plus-CSRmdP_D.js";import{M as $}from"./message-square-CQQno_qi.js";import{C as E}from"./chart-column-DIo4-TcE.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const I=f("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const M=f("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);function X(){const d=k(),[t,v]=r.useState({totalLeads:0,newLeads:0,convertedLeads:0,totalPosts:0,totalViews:0,recentLeads:[],recentConversations:[]}),u=r.useRef(t),[i,j]=r.useState({totalLeads:{value:0,change:0},newLeads:{value:0,change:0},convertedLeads:{value:0,change:0},totalViews:{value:0,change:0}}),[q,h]=r.useState(!0),[x,g]=r.useState(!1),[b,N]=r.useState(new Date),[n,w]=r.useState(!0),l=r.useCallback(async()=>{try{const s=await A.dashboard.getStats(),a={totalLeads:s.totalLeads||0,newLeads:s.newLeads||0,convertedLeads:s.convertedLeads||0,totalPosts:s.totalPosts||0,totalViews:s.totalViews||0,recentLeads:s.recentLeads||[],recentConversations:s.recentConversations||[]},c=u.current;j({totalLeads:{value:a.totalLeads,change:a.totalLeads-c.totalLeads},newLeads:{value:a.newLeads,change:a.newLeads-c.newLeads},convertedLeads:{value:a.convertedLeads,change:a.convertedLeads-c.convertedLeads},totalViews:{value:a.totalViews,change:a.totalViews-c.totalViews}}),v(a),u.current=a,N(new Date)}catch(s){console.error("Failed to fetch stats:",s)}},[]);r.useEffect(()=>{(async()=>{h(!0),await l(),h(!1)})()},[l]),r.useEffect(()=>{if(!n)return;const s=setInterval(()=>{l()},6e4);return()=>clearInterval(s)},[n,l]);const L=async()=>{g(!0),await l(),g(!1)},y=t.totalLeads>0?(t.convertedLeads/t.totalLeads*100).toFixed(1):"0.0",C=t.totalLeads>0?(t.newLeads/t.totalLeads*100).toFixed(0):"0",R=s=>s>0?"text-green-600":s<0?"text-red-600":"text-gray-500",S=s=>s>0?e.jsx(M,{className:"w-4 h-4"}):s<0?e.jsx(I,{className:"w-4 h-4"}):null,V=[{label:"Total Leads",value:t.totalLeads,icon:P,color:"text-primary",subtext:`${C}% new`,trend:i.totalLeads.change},{label:"Conversion Rate",value:`${y}%`,icon:D,color:"text-accent",subtext:`${t.convertedLeads} converted`,trend:i.convertedLeads.change},{label:"Blog Posts",value:t.totalPosts,icon:p,color:"text-purple",subtext:"Published"},{label:"Page Views",value:t.totalViews.toLocaleString(),icon:F,color:"text-amber",subtext:"All time",trend:i.totalViews.change}];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-display font-bold text-foreground",children:"Dashboard"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Last updated: ",b.toLocaleTimeString(),n&&" (Auto-refresh: on)"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(o,{onClick:()=>w(!n),variant:"outline",size:"sm",className:n?"bg-primary/10":"",children:n?"Auto-refresh: ON":"Auto-refresh: OFF"}),e.jsxs(o,{onClick:L,disabled:x,variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(T,{className:`w-4 h-4 ${x?"animate-spin":""}`}),x?"Refreshing...":"Refresh"]})]})]}),e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-4 gap-4",children:V.map(s=>e.jsx(m,{className:"p-6 hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s.label}),e.jsx("p",{className:"text-3xl font-display font-bold text-foreground mt-2",children:s.value}),e.jsxs("div",{className:"flex items-center gap-1 mt-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s.subtext}),s.trend!==void 0&&e.jsxs("div",{className:`flex items-center gap-0.5 text-xs font-medium ${R(s.trend)}`,children:[S(s.trend),e.jsxs("span",{children:[s.trend>0?"+":"",s.trend]})]})]})]}),e.jsx(s.icon,{className:`w-8 h-8 ${s.color} opacity-60 shrink-0`})]})},s.label))}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-display font-semibold text-foreground mb-3",children:"Qu
11ick Actions"}),e.jsxs("div",{className:"grid sm:grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsxs(o,{onClick:()=>d("/admin/leads"),className:"h-20 flex flex-col items-center justify-center gap-2 bg-primary/10 hover:bg-primary/20 text-foreground border border-primary/20",variant:"outline",children:[e.jsx(U,{className:"w-5 h-5"}),e.jsx("span",{className:"text-xs",children:"View Leads"})]}),e.jsxs(o,{onClick:()=>d("/admin/blog"),className:"h-20 flex flex-col items-center justify-center gap-2 bg-purple/10 hover:bg-purple/20 text-foreground border border-purple/20",variant:"outline",children:[e.jsx(p,{className:"w-5 h-5"}),e.jsx("span",{className:"text-xs",children:"Publish Post"})]}),e.jsxs(o,{onClick:()=>d("/admin/chat"),className:"h-20 flex flex-col items-center justify-center gap-2 bg-accent/10 hover:bg-accent/20 text-foreground border border-accent/20",variant:"outline",children:[e.jsx($,{className:"w-5 h-5"}),e.jsx("span",{className:"text-xs",children:"View Chat"})]}),e.jsxs(o,{onClick:()=>d("/admin/analytics"),className:"h-20 flex flex-col items-center justify-center gap-2 bg-amber/10 hover:bg-amber/20 text-foreground border border-amber/20",variant:"outline",children:[e.jsx(E,{className:"w-5 h-5"}),e.jsx("span",{className:"text-xs",children:"Analytics"})]})]})]}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-6",children:[e.jsxs(m,{className:"p-6",children:[e.jsx("h3",{className:"font-display font-semibold text-foreground mb-4",children:"Recent Leads"}),e.jsx("div",{className:"space-y-3",children:t.recentLeads.length>0?t.recentLeads.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/30 rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:s.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.email})]}),e.jsx("span",{className:`text-xs px-2 py-1 rounded ${s.status==="new"?"bg-primary/20 text-primary":s.status==="won"?"bg-green-500/20 text-green-600":"bg-muted"}`,children:s.status||"pending"})]},s.id)):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No leads yet"})})]}),e.jsxs(m,{className:"p-6",children:[e.jsx("h3",{className:"font-display font-semibold text-foreground mb-4",children:"Recent Chats"}),e.jsx("div",{className:"space-y-3",children:t.recentConversations.length>0?t.recentConversations.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/30 rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:s.visitorName||"Anonymous"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(s.updatedAt).toLocaleDateString()})]}),e.jsx("span",{className:`text-xs px-2 py-1 rounded ${s.status==="open"?"bg-accent/20 text-accent":s.status==="resolved"?"bg-green-500/20 text-green-600":"bg-muted"}`,children:s.status||"pending"})]},s.id)):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No conversations yet"})})]})]})]})}export{X 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.