import { Geist, Geist_Mono } from "next/font/google";
import { NextAuthSessionProvider } from "./_components/AuthSessionProvider";
import { getServerSession } from "./api/auth/[...nextauth]/auth";
import "./globals.css";
import { CustomErrorBoundary } from "_components/ErrorBoundary";

const geistSans = Geist({
	variable: "--font-geist-sans",
	subsets: ["latin"],
});

const geistMono = Geist_Mono({
	variable: "--font-geist-mono",
	subsets: ["latin"],
});

const RootLayout = async ({
	children,
}: Readonly<{
	children: React.ReactNode;
}>) => {
	const session = await getServerSession();

	return (
		<html lang="en">
			<NextAuthSessionProvider session={session}>
				<body className={`${geistSans.variable} ${geistMono.variable} antialiased`}>
					<CustomErrorBoundary>{children}</CustomErrorBoundary>
				</body>
			</NextAuthSessionProvider>
		</html>
	);
};

RootLayout.displayName = "RootLayout";

export default RootLayout;
