"use client"; import { ReactNode } from "react"; import { useSession, signOut } from "next-auth/react"; import { useRouter } from "next/navigation"; import Sidebar from "../../components/Sidebar"; export default function DashboardLayout({ children }: { children: ReactNode }) { // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars const { data: session, status } = useSession(); const router = useRouter(); // Redirect if not authenticated if (status === "unauthenticated") { router.push("/login"); return (
Redirecting to login...
); } // Show loading state while session status is being determined if (status === "loading") { return (
Loading session...
); } // Defined for potential future use, like adding a logout button in the layout // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars const handleLogout = () => { signOut({ callbackUrl: "/login" }); }; return (
{/* Sidebar with logout handler passed as prop */} {/* Main content */}
{children}
); }