import type { Metadata } from "next";
import Navbar from "./_components/navbar/Navbar";
import { redirect } from "next/navigation";
import { getServerSession } from "../api/auth/[...nextauth]/auth";
import { Toaster } from "react-hot-toast";

export const metadata: Metadata = {
	title: "VAR Leitstelle v2",
	description: "Die neue VAR Leitstelle.",
};

export default async function RootLayout({
	children,
}: Readonly<{
	children: React.ReactNode;
}>) {
	const session = await getServerSession();
	if (!session) {
		redirect("/login");
	}
	return (
		<>
			<Toaster
				containerStyle={{
					top: 150,
					left: 20,
					right: 20,
				}}
				toastOptions={{
					style: {
						background: "var(--color-base-100)",
						color: "var(--color-base-content)",
					},
				}}
				position="top-left"
				reverseOrder={false}
			/>
			<Navbar />
			{children}
		</>
	);
}
