| 1 | import { Header } from "@/components/header"; |
| 2 | import { auth } from "@/server/auth"; |
| 3 | import { headers } from "next/headers"; |
| 4 | import { redirect } from "next/navigation"; |
| 5 | |
| 6 | export default async function DashboardLayout({ |
| 7 | children, |
| 8 | }: { |
| 9 | children: React.ReactNode; |
| 10 | }) { |
| 11 | const session = await auth.api.getSession({ headers: await headers() }); |
| 12 | if (!session?.user) { |
| 13 | redirect("/sign-in"); |
| 14 | } |
| 15 | return ( |
| 16 | <div className="min-h-screen bg-background"> |
| 17 | <Header user={session.user} /> |
| 18 | <main className="container mx-auto px-4 py-8">{children}</main> |
| 19 | </div> |
| 20 | ); |
| 21 | } |