import{r,s as t,j as e,L as b}from"./index-CEqTxpJr.js";function g(){const[s,a]=r.useState({projects:0,blogs:0,leads:0}),[o,d]=r.useState(null);return r.useEffect(()=>{(async()=>{const{data:n}=await t.auth.getUser();if(n.user){const{data:u}=await t.from("user_roles").select("role").eq("user_id",n.user.id);d(!!u?.some(x=>x.role==="admin"))}const[i,c,m]=await Promise.all([t.from("projects").select("*",{count:"exact",head:!0}),t.from("blog_posts").select("*",{count:"exact",head:!0}),t.from("leads").select("*",{count:"exact",head:!0})]);a({projects:i.count??0,blogs:c.count??0,leads:m.count??0})})()},[]),e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-3xl font-bold",children:"Dashboard"}),o===!1&&e.jsx("div",{className:"mt-4 border border-amber-500/40 bg-amber-50 p-4 text-sm",children:"Your account is not yet an admin. Lead inserts, project edits, and blog edits will be denied until an admin role is granted to you in the database."}),e.jsxs("div",{className:"mt-8 grid gap-6 sm:grid-cols-3",children:[e.jsx(l,{label:"Projects",value:s.projects,to:"/admin/projects"}),e.jsx(l,{label:"Blog Posts",value:s.blogs,to:"/admin/blogs"}),e.jsx(l,{label:"Leads",value:s.leads,to:"/admin/leads"})]})]})}function l({label:s,value:a,to:o}){return e.jsxs(b,{to:o,className:"block bg-white p-6 ring-1 ring-navy/10 hover:ring-gold",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-widest text-navy/40",children:s}),e.jsx("div",{className:"mt-2 font-display text-4xl font-extrabold text-navy",children:a})]})}export{g as component};
