2025-09-21 11:02:31 -07:00
|
|
|
import { cookies } from "next/headers";
|
|
|
|
|
import Script from "next/script";
|
2025-11-29 13:21:34 +00:00
|
|
|
import { Suspense } from "react";
|
2025-09-21 11:02:31 -07:00
|
|
|
import { AppSidebar } from "@/components/app-sidebar";
|
|
|
|
|
import { DataStreamProvider } from "@/components/data-stream-provider";
|
|
|
|
|
import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar";
|
|
|
|
|
import { auth } from "../(auth)/auth";
|
2024-10-24 16:35:51 -04:00
|
|
|
|
2025-11-29 13:21:34 +00:00
|
|
|
export default function Layout({ children }: { children: React.ReactNode }) {
|
2024-10-24 16:35:51 -04:00
|
|
|
return (
|
2024-12-16 18:14:40 +05:30
|
|
|
<>
|
|
|
|
|
<Script
|
|
|
|
|
src="https://cdn.jsdelivr.net/pyodide/v0.23.4/full/pyodide.js"
|
|
|
|
|
strategy="beforeInteractive"
|
|
|
|
|
/>
|
2025-07-03 02:26:34 -07:00
|
|
|
<DataStreamProvider>
|
2025-11-29 13:21:34 +00:00
|
|
|
<Suspense fallback={<div className="flex h-dvh" />}>
|
|
|
|
|
<SidebarWrapper>{children}</SidebarWrapper>
|
|
|
|
|
</Suspense>
|
2025-07-03 02:26:34 -07:00
|
|
|
</DataStreamProvider>
|
2024-12-16 18:14:40 +05:30
|
|
|
</>
|
2024-10-24 16:35:51 -04:00
|
|
|
);
|
|
|
|
|
}
|
2025-11-29 13:21:34 +00:00
|
|
|
|
|
|
|
|
async function SidebarWrapper({ children }: { children: React.ReactNode }) {
|
|
|
|
|
const [session, cookieStore] = await Promise.all([auth(), cookies()]);
|
|
|
|
|
const isCollapsed = cookieStore.get("sidebar_state")?.value !== "true";
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<SidebarProvider defaultOpen={!isCollapsed}>
|
|
|
|
|
<AppSidebar user={session?.user} />
|
|
|
|
|
<SidebarInset>{children}</SidebarInset>
|
|
|
|
|
</SidebarProvider>
|
|
|
|
|
);
|
|
|
|
|
}
|