Files

33 lines
1.2 KiB
TypeScript
Raw Permalink Normal View History

2026-02-26 15:29:00 +01:00
import { ReactNode } from "react";
2026-02-25 13:00:52 +01:00
import { redirect } from "next/navigation";
2024-11-10 23:12:38 +01:00
2026-02-25 13:00:52 +01:00
import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar";
2026-06-27 17:08:38 +02:00
import { AppSidebar } from "@/features/layout/components/app-sidebar";
import { Header } from "@/features/layout/components/header";
2026-02-25 13:00:52 +01:00
import { currentUser } from "@/lib/auth/current-user";
2026-06-27 17:08:38 +02:00
import { isOnboardingDone } from "@/db/services/setting";
import { env } from "@/env.mjs";
import { ModeToggle } from "@/features/theme/components/mode-toggle";
import { UpdateNotification } from "@/features/updates/components/update-notification";
2026-02-25 13:00:52 +01:00
export default async function Layout({ children }: { children: ReactNode }) {
2026-06-27 17:08:38 +02:00
if (env.SKIP_ONBOARDING !== "true" && !(await isOnboardingDone())) {
redirect("/welcome");
}
2026-02-25 13:00:52 +01:00
const user = await currentUser();
if (!user) redirect("/login");
2024-11-10 23:12:38 +01:00
2026-02-25 13:00:52 +01:00
return (
<SidebarProvider>
<div className="flex flex-col lg:flex-row w-full">
2026-05-24 17:09:12 +02:00
<AppSidebar updateNotification={<UpdateNotification />} />
2026-02-25 13:00:52 +01:00
<SidebarInset>
2026-05-24 17:09:12 +02:00
<Header actions={<ModeToggle />} />
2026-02-26 15:29:00 +01:00
<main className="h-full">{children}</main>
2026-02-25 13:00:52 +01:00
</SidebarInset>
</div>
</SidebarProvider>
);
2025-05-16 15:54:17 +02:00
}