41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import type { Metadata } from "next";
|
|
import { Inter } from "next/font/google";
|
|
import "./globals.css";
|
|
import { headers } from "next/headers";
|
|
import { getServerSession } from "next-auth/next";
|
|
import { authOptions } from "@/lib/auth";
|
|
import { Providers } from "@/components/providers";
|
|
import { LayoutWrapper } from "@/components/layout/layout-wrapper";
|
|
import { Toaster } from "@/components/ui/toaster";
|
|
|
|
const inter = Inter({ subsets: ["latin"] });
|
|
|
|
export default async function RootLayout({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode;
|
|
}) {
|
|
const headersList = headers();
|
|
const pathname = headersList.get("x-pathname") || "";
|
|
const isSignInPage = pathname === "/signin";
|
|
|
|
// Only check session if not on signin page
|
|
const session = !isSignInPage ? await getServerSession(authOptions) : null;
|
|
|
|
return (
|
|
<html lang="fr">
|
|
<body className={inter.className}>
|
|
<Providers>
|
|
<LayoutWrapper
|
|
isSignInPage={isSignInPage}
|
|
isAuthenticated={!!session}
|
|
>
|
|
{children}
|
|
</LayoutWrapper>
|
|
</Providers>
|
|
<Toaster />
|
|
</body>
|
|
</html>
|
|
);
|
|
}
|