MCPcopy Create free account
hub / github.com/GreatStackDev/gocart / AdminLayout

Function AdminLayout

components/admin/AdminLayout.jsx:9–43  ·  view source on GitHub ↗
({ children })

Source from the content-addressed store, hash-verified

7import AdminSidebar from "./AdminSidebar"
8
9const AdminLayout = ({ children }) => {
10
11 const [isAdmin, setIsAdmin] = useState(false)
12 const [loading, setLoading] = useState(true)
13
14 const fetchIsAdmin = async () => {
15 setIsAdmin(true)
16 setLoading(false)
17 }
18
19 useEffect(() => {
20 fetchIsAdmin()
21 }, [])
22
23 return loading ? (
24 <Loading />
25 ) : isAdmin ? (
26 <div className="flex flex-col h-screen">
27 <AdminNavbar />
28 <div className="flex flex-1 items-start h-full overflow-y-scroll no-scrollbar">
29 <AdminSidebar />
30 <div className="flex-1 h-full p-5 lg:pl-12 lg:pt-12 overflow-y-scroll">
31 {children}
32 </div>
33 </div>
34 </div>
35 ) : (
36 <div className="min-h-screen flex flex-col items-center justify-center text-center px-6">
37 <h1 className="text-2xl sm:text-4xl font-semibold text-slate-400">You are not authorized to access this page</h1>
38 <Link href="/" className="bg-slate-700 text-white flex items-center gap-2 mt-8 p-2 px-6 max-sm:text-sm rounded-full">
39 Go to home <ArrowRightIcon size={18} />
40 </Link>
41 </div>
42 )
43}
44
45export default AdminLayout

Callers

nothing calls this directly

Calls 1

fetchIsAdminFunction · 0.85

Tested by

no test coverage detected