1import{u as c,U as f,ah as q,j as e,C as n,e as l,f as o,a as d,g as j,h as b,s as r}from"./index-CLtGP32Z.js";import{B as p}from"./badge-BKvD35-V.js";import{T,a as D,b as g,c as m,d as F,e as u}from"./table-VQ_0MYAS.js";import{F as M}from"./file-text-BL-ZejJn.js";import{N as B,M as N}from"./newspaper-xPzFCBgf.js";import{P as S}from"./plus-DFFH5FJe.js";import{M as A}from"./mail-BrhL5Kus.js";const Q=()=>{const{data:t}=c({queryKey:["admin-stats"],queryFn:async()=>{const[s,a,_,C,P]=await Promise.all([r.from("team_members").select("*",{count:"exact",head:!0}),r.from("publications").select("*",{count:"exact",head:!0}),r.from("blog_posts").select("*",{count:"exact",head:!0}),r.from("research_projects").select("*",{count:"exact",head:!0}),r.from("contact_submissions").select("*",{count:"exact",head:!0})]);return{teamMembers:s.count||0,publications:a.count||0,blogPosts:_.count||0,researchProjects:C.count||0,contactSubmissions:P.count||0}}}),{data:x}=c({queryKey:["admin-recent-contacts"],queryFn:async()=>{const{data:s,error:a}=await r.from("contact_submissions").select("id, name, email, subject, status, created_at").order("created_at",{ascending:!1}).limit(5);if(a)throw a;return s}}),{data:h}=c({queryKey:["admin-recent-posts"],queryFn:async()=>{const{data:s,error:a}=await r.from("blog_posts").select("id, title, is_published, created_at").order("created_at",{ascending:!1}).limit(5);if(a)throw a;return s}});c({queryKey:["admin-recent-applications"],queryFn:async()=>{const{data:s,error:a}=await r.from("job_applications").select("id, first_name, last_name, email, status, created_at, position_id").order("created_at",{ascending:!1}).limit(5);if(a)throw a;return s}});const{data:i}=c({queryKey:["admin-newsletter-stats"],queryFn:async()=>{const[s,a]=await Promise.all([r.from("newsletter_subscribers").select("*",{count:"exact",head:!0}),r.from("newsletter_subscribers").select("*",{count:"exact",head:!0}).eq("is_active",!0)]);return{total:s.count||0,active:a.count||0}}}),y=[{title:"Team Members",value:(t==null?void 0:t.teamMembers)||0,icon:f},{title:"Publications",value:(t==null?void 0:t.publications)||0,icon:M},{title:"Blog Posts",value:(t==null?void 0:t.blogPosts)||0,icon:B},{title:"Research Projects",value:(t==null?void 0:t.researchProjects)||0,icon:q},{title:"Contact Submissions",value:(t==null?void 0:t.contactSubmissions)||0,icon:N}],w=[{label:"New Blog Post",icon:S,to:"/admin/blog"},{label:"Add Team Member",icon:f,to:"/admin/team"},{label:"View Contacts",icon:N,to:"/admin/contacts"},{label:"Newsletter",icon:A,to:"/admin/newsletter"}],v=s=>{switch(s){case"new":return"default";case"read":return"secondary";case"replied":return"outline";case"archived":return"outline";default:return"default"}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Dashboard"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"Overview of your content and activity"})]}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:y.map(s=>e.jsxs(n,{children:[e.jsxs(l,{className:"flex flex-row items-center justify-between pb-2",children:[e.jsx(o,{className:"text-sm font-medium",children:s.title}),e.jsx(s.icon,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(d,{children:e.jsx("div",{className:"text-2xl font-bold",children:s.value})})]},s.title))}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(n,{children:[e.jsx(l,{children:e.jsx(o,{children:"Quick Actions"})}),e.jsx(d,{children:e.jsx("div",{className:"grid grid-cols-2 gap-3",children:w.map(s=>e.jsx(j,{variant:"outline",className:"justify-start",asChild:!0,children:e.jsxs(b,{to:s.to,children:[e.jsx(s.icon,{className:"h-4 w-4 mr-2"}),s.label]})},s.label))})})]}),e.jsxs(n,{children:[e.jsx(l,{children:e.jsx(o,{children:"Newsletter"})}),e.jsx(d,{children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Subscribers"}),e.jsx("p",{className:"text-2xl font-bold",children:(i==null?void 0:i.total)||0})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Active"}),e.jsx("p",{className:"text-2xl font-bold",children:(i==null?void 0:i.active)||0})]})]})})]})]}),e.jsxs(n,{children:[e.jsxs(l,{className:"flex flex-row items-center justify-between",children:[e.jsx(o,{children:"Recent
1Contact Submissions"}),e.jsx(j,{variant:"outline",size:"sm",asChild:!0,children:e.jsx(b,{to:"/admin/contacts",children:"View All"})})]}),e.jsx(d,{children:x&&x.length>0?e.jsxs(T,{children:[e.jsx(D,{children:e.jsxs(g,{children:[e.jsx(m,{children:"Name"}),e.jsx(m,{children:"Subject"}),e.jsx(m,{children:"Status"}),e.jsx(m,{children:"Date"})]})}),e.jsx(F,{children:x.map(s=>e.jsxs(g,{children:[e.jsx(u,{className:"font-medium",children:s.name}),e.jsx(u,{className:"max-w-[200px] truncate",children:s.subject}),e.jsx(u,{children:e.jsx(p,{variant:v(s.status),children:s.status})}),e.jsx(u,{className:"text-muted-foreground text-sm",children:new Date(s.created_at).toLocaleDateString()})]},s.id))})]}):e.jsx("p",{className:"text-muted-foreground text-sm",children:"No contact submissions yet."})})]}),e.jsxs(n,{children:[e.jsxs(l,{className:"flex flex-row items-center justify-between",children:[e.jsx(o,{children:"Recent Blog Posts"}),e.jsx(j,{variant:"outline",size:"sm",asChild:!0,children:e.jsx(b,{to:"/admin/blog",children:"View All"})})]}),e.jsx(d,{children:h&&h.length>0?e.jsx("div",{className:"space-y-3",children:h.map(s=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium truncate",children:s.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(s.created_at).toLocaleDateString()})]}),e.jsx(p,{variant:s.is_published?"default":"secondary",children:s.is_published?"Published":"Draft"})]},s.id))}):e.jsx("p",{className:"text-muted-foreground text-sm",children:"No blog posts yet."})})]})]})};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.