27 lines
728 B
TypeScript
27 lines
728 B
TypeScript
import { redirect } from "next/navigation";
|
|
|
|
import { isAuthenticated } from "@/lib/auth-server";
|
|
import { DashboardSidebar } from "@/components/dashboard-sidebar";
|
|
import { DashboardThemeProvider } from "@/components/dashboard-theme";
|
|
import { getDashboardRedirectPath } from "@/lib/route-guards";
|
|
|
|
export default async function DashboardLayout({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode;
|
|
}) {
|
|
const hasSession = await isAuthenticated();
|
|
const redirectPath = getDashboardRedirectPath(hasSession);
|
|
|
|
if (redirectPath) {
|
|
redirect(redirectPath ?? "/");
|
|
}
|
|
|
|
return (
|
|
<DashboardThemeProvider>
|
|
<DashboardSidebar />
|
|
<div className="min-w-0 flex-1">{children}</div>
|
|
</DashboardThemeProvider>
|
|
);
|
|
}
|