mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 10:12:09 +01:00
Introduce company settings, user management, and layout components Implement session-based Company and User pages for admin access Integrate chart components for dynamic data visualization Add Sidebar for modular navigation Revamp global styles with Tailwind CSS Enhances user experience and administrative control
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
"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 }) {
|
|
const { data: session, status } = useSession();
|
|
const router = useRouter();
|
|
|
|
// Redirect if not authenticated
|
|
if (status === "unauthenticated") {
|
|
router.push("/login");
|
|
return (
|
|
<div className="flex h-screen items-center justify-center">
|
|
<div className="text-center">Redirecting to login...</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
// Show loading state while session status is being determined
|
|
if (status === "loading") {
|
|
return (
|
|
<div className="flex h-screen items-center justify-center">
|
|
<div className="text-center">Loading session...</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
const handleLogout = () => {
|
|
signOut({ callbackUrl: "/login" });
|
|
};
|
|
|
|
return (
|
|
<div className="flex h-screen bg-gray-100">
|
|
{/* Sidebar with logout handler passed as prop */}
|
|
<Sidebar />
|
|
|
|
{/* Main content */}
|
|
<div className="flex-1 overflow-auto p-8">
|
|
<div className="mx-auto max-w-7xl">{children}</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|