import { redirect } from "next/navigation"; import { sidebarLinks } from "@/config/dashboard"; import { getCurrentUser } from "@/lib/session"; import { SearchCommand } from "@/components/dashboard/search-command"; import { DashboardSidebar, MobileSheetSidebar, } from "@/components/layout/dashboard-sidebar"; import { ModeToggle } from "@/components/layout/mode-toggle"; import { UserAccountNav } from "@/components/layout/user-account-nav"; import MaxWidthWrapper from "@/components/shared/max-width-wrapper"; interface ProtectedLayoutProps { children: React.ReactNode; } export default async function Dashboard({ children }: ProtectedLayoutProps) { const user = await getCurrentUser(); if (!user) redirect("/login"); const filteredLinks = sidebarLinks.map((section) => ({ ...section, items: section.items.filter( ({ authorizeOnly }) => !authorizeOnly || authorizeOnly === user.role, ), })); return (