PageSourceSearch

https://grad-teched.lovable.app/assets/route-wwuXZvwk.js

js grad-teched.lovable.app collected 2026-10-03 03:27:53 UTC 4,379 bytes, 1 lines download raw bytes

1import{u as y,r as d,s as o,t as u,j as e,O as x,L as c}from"./index-BPeZ_r1q.js";import{u as j}from"./useRouterState-BXPTCRNq.js";import{c as w}from"./utils-BQHNewu7.js";import{G as N}from"./graduation-cap-CsVMetVr.js";import{c as h}from"./createLucideIcon-sAK5O1_0.js";import{N as v}from"./newspaper-CuWwzNrM.js";import{B as k}from"./book-open-dd1Jbdyz.js";import{F as L}from"./file-text-DcxBcLGP.js";import{U as _}from"./users-DsO5lmWo.js";import{E}from"./external-link-DM_F6bWg.js";const O=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],z=h("layout-dashboard",O);const S=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],C=h("log-out",S),R=[{to:"/admin",label:"แดชบอร์ด",icon:z,exact:!0},{to:"/admin/news",label:"จัดการข่าว",icon:v},{to:"/admin/programs",label:"จัดการหลักสูตร",icon:k},{to:"/admin/documents",label:"เอกสาร/แบบฟอร์ม",icon:L},{to:"/admin/staff",label:"เจ้าหน้าที่",icon:_}];function T(){const r=y(),t=j({select:s=>s.location.pathname}),i=t==="/admin/login",[p,g]=d.useState(!i),[l,f]=d.useState(null);if(d.useEffect(()=>{if(i||!t.startsWith("/admin"))return;(async()=>{const{data:a}=await o.auth.getSession();if(!t.startsWith("/admin")||t==="/admin/login")return;if(!a.session){r({to:"/admin/login"});return}const{data:n}=await o.from("user_roles").select("role").eq("user_id",a.session.user.id);if(!(n??[]).some(m=>m.role==="admin"||m.role==="staff")){await o.auth.signOut(),u.error("บัญชีนี้ไม่มีสิทธิ์เข้าถึงระบบจัดการ"),r({to:"/admin/login"});return}f(a.session.user.email??null),g(!1)})();const{data:s}=o.auth.onAuthStateChange((a,n)=>{!n&&window.location.pathname.startsWith("/admin")&&window.location.pathname!=="/admin/login"&&r({to:"/admin/login"})});return()=>s.subscription.unsubscribe()},[r,i,t]),i)return e.jsx(x,{});if(p)return e.jsx("div",{className:"min-h-screen grid place-items-center bg-background",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"กำลังโหลด..."})});const b=async()=>{await o.auth.signOut(),u.success("ออกจากระบบแล้ว"),r({to:"/admin/login"})};return e.jsxs("div",{className:"min-h-screen flex bg-secondary/30",children:[e.jsxs("aside",{className:"w-64 bg-sidebar text-sidebar-foreground flex flex-col",children:[e.jsxs(c,{to:"/",className:"flex items-center gap-3 p-5 border-b border-sidebar-border",children:[e.jsx("div",{className:"grid size-10 place-items-center rounded-xl bg-gradient-primary shadow-glow",children:e.jsx(N,{className:"size-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-bold",children:"ระบบจัดการ"}),e.jsx("div",{className:"text-[10px] opacity-70",children:"งานบัณฑิตศึกษา"})]})]}),e.jsx("nav",{className:"flex-1 p-3 space-y-1",children:R.map(s=>{const a=s.exact?t===s.to:t.startsWith(s.to);return e.jsxs(c,{to:s.to,className:w("flex items-center gap-3 rounded-lg px-3 py-2.5 text-sm transition",a?"bg-sidebar-primary text-sidebar-primary-foreground shadow-glow":"text-sidebar-foreground/80 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[e.jsx(s.icon,{className:"size-4"}),s.label]},s.to)})}),e.jsxs("div",{className:"p-3 border-t border-sidebar-border space-y-1",children:[e.jsxs(c,{to:"/",className:"flex items-center gap-3 rounded-lg px-3 py-2 text-xs text-sidebar-foreground/70 hover:text-sidebar-foreground transition",children:[e.jsx(E,{className:"size-3.5"})," ดูเว็บไซต์"]}),e.jsxs("button",{onClick:b,className:"w-full flex items-center gap-3 rounded-lg px-3 py-2 text-xs text-sidebar-foreground/70 hover:text-sidebar-foreground transition",children:[e.jsx(C,{className:"size-3.5"})," ออกจากระบบ"]}),l&&e.jsx("div",{className:"px-3 pt-2 text-[10px] opacity-50 truncate",children:l})]})]}),e.jsx("main",{className:"flex-1 overflow-x-auto",children:e.jsx(x,{})})]})}export{T 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.