import { createRootRouteWithContext, Outlet } from "@tanstack/react-router";
import { TanStackRouterDevtools } from "@tanstack/react-router-devtools";
import type { QueryClient } from "@tanstack/react-query";
import { Toaster } from "sonner";
import { SessionGuard } from "../lib/providers/SessionProvider";
import Nav from "../components/navBar/Nav";

interface RootRouteContext {
    queryClient: QueryClient;
    //user: User | null;
    //login: (user: User) => void;
    //logout: () => void;
}

const RootLayout = () => {
    //const { logout, login } = Route.useRouteContext();

    return (
        <div>
            <SessionGuard>
                <Nav />
                <Outlet />
                <Toaster expand={true} richColors closeButton />
                <TanStackRouterDevtools />
            </SessionGuard>
        </div>
    );
};

export const Route = createRootRouteWithContext<RootRouteContext>()({
    component: RootLayout,
});
