Spaces:
Sleeping
Sleeping
Download apps/admin/src/app/(dashboard)/layout.tsx from Benaah/MicProtocol: direct link, hf CLI and curl.
- Browser
- Download file 1.3 kB
-
https://huggingface.co/spaces/Benaah/MicProtocol/resolve/main/apps/admin/src/app/(dashboard)/layout.tsx
- Command line
-
hf download 'hf://spaces/Benaah/MicProtocol/apps/admin/src/app/(dashboard)/layout.tsx'
-
curl -L -o layout.tsx 'https://huggingface.co/spaces/Benaah/MicProtocol/resolve/main/apps/admin/src/app/(dashboard)/layout.tsx'
1.3 kB
| "use client"; | |
| import { useSession } from "@/lib/auth-client"; | |
| import { useRouter } from "next/navigation"; | |
| import { useEffect } from "react"; | |
| import { AdminSidebar } from "@/components/shell/AdminSidebar"; | |
| export default function DashboardLayout({ children }: { children: React.ReactNode }) { | |
| const session = useSession(); | |
| const router = useRouter(); | |
| // Redirect unauthenticated users to login after mount (avoid SSR flash) | |
| useEffect(() => { | |
| if (!session.isPending && !session.data) { | |
| router.replace("/login"); | |
| } | |
| }, [session, router]); | |
| // While session is still loading, show a neutral shell | |
| if (session.isPending) { | |
| return ( | |
| <div className="flex h-screen items-center justify-center bg-[var(--bg-primary)]"> | |
| <div className="flex flex-col items-center gap-3"> | |
| <div className="h-8 w-8 rounded-full border-2 border-t-[var(--color-primary)] animate-spin" /> | |
| <p className="text-sm text-[var(--text-secondary)]">Signing in…</p> | |
| </div> | |
| </div> | |
| ); | |
| } | |
| if (!session.data) { | |
| return null; | |
| } | |
| return ( | |
| <div className="flex h-screen overflow-hidden bg-[var(--bg-primary)] text-[var(--text-primary)]"> | |
| <AdminSidebar /> | |
| <main className="flex-1 overflow-y-auto">{children}</main> | |
| </div> | |
| ); | |
| } | |