1import{d as u,e as p,f as h,u as f,r as c,s as m,j as e,L as s,O as g}from"./index-BY4i7iah.js";import{u as b}from"./useServerFn-T-IZ25l8.js";import{B as d}from"./button-DlCathSZ.js";const v=u({method:"POST"}).middleware([p]).handler(h("a3ccb93e8665d6db1768fbd2a5d92b31924e354ab917d7fd403fa93b39b20c13"));function w(){const t=f(),[i,n]=c.useState("loading"),r=b(v);c.useEffect(()=>{let a=!0;return(async()=>{const{data:l}=await m.auth.getSession();if(!l.session){t({to:"/login"});return}try{const x=await r();if(!a)return;n(x.isAdmin?"ok":"no-admin")}catch{a&&n("no-admin")}})(),()=>{a=!1}},[t,r]);async function o(){await m.auth.signOut(),t({to:"/login"})}return i==="loading"?e.jsx("div",{className:"max-w-7xl mx-auto px-6 py-20 text-muted-foreground",children:"Laddarâ¦"}):i==="no-admin"?e.jsxs("div",{className:"max-w-md mx-auto px-6 py-20",children:[e.jsx("h1",{className:"text-2xl font-semibold text-primary",children:"Inget admin-konto"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Ditt konto har inte adminbehörighet. Kontakta en befintlig admin."}),e.jsx(d,{variant:"outline",className:"mt-6",onClick:o,children:"Logga ut"})]}):e.jsxs("div",{className:"max-w-7xl mx-auto px-6 py-10",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border pb-4 mb-8",children:[e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsx("h1",{className:"text-xl font-semibold text-primary",children:"Admin"}),e.jsxs("nav",{className:"flex gap-4 text-sm text-muted-foreground",children:[e.jsx(s,{to:"/admin",className:"hover:text-accent",activeOptions:{exact:!0},activeProps:{className:"text-primary"},children:"Inlägg"}),e.jsx(s,{to:"/admin/experts",className:"hover:text-accent",activeProps:{className:"text-primary"},children:"Experter"}),e.jsx(s,{to:"/admin/import",className:"hover:text-accent",activeProps:{className:"text-primary"},children:"Import"})]})]}),e.jsx(d,{variant:"ghost",size:"sm",onClick:o,children:"Logga ut"})]}),e.jsx(g,{})]})}export{w as component};
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.