diff options
| author | Mohamed Bassem <me@mbassem.com> | 2024-12-30 11:27:32 +0000 |
|---|---|---|
| committer | Mohamed Bassem <me@mbassem.com> | 2024-12-30 11:31:35 +0000 |
| commit | 179f00b15525b024b6823088ef8fb94b7106b4f0 (patch) | |
| tree | d64257778930965ed076ff9a081411470343fb3c /apps/web/app/admin/layout.tsx | |
| parent | aff4e60952321d06dc4cf517ff3b15206aaaebba (diff) | |
| download | karakeep-179f00b15525b024b6823088ef8fb94b7106b4f0.tar.zst | |
feat: Change the admin page to be tabbed similar to that of the settings page
Diffstat (limited to 'apps/web/app/admin/layout.tsx')
| -rw-r--r-- | apps/web/app/admin/layout.tsx | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/apps/web/app/admin/layout.tsx b/apps/web/app/admin/layout.tsx new file mode 100644 index 00000000..0d876736 --- /dev/null +++ b/apps/web/app/admin/layout.tsx @@ -0,0 +1,40 @@ +import { redirect } from "next/navigation"; +import { AdminCard } from "@/components/admin/AdminCard"; +import { AdminNotices } from "@/components/admin/AdminNotices"; +import MobileAdminSidebar from "@/components/admin/sidebar/MobileSidebar"; +import AdminSidebar from "@/components/admin/sidebar/Sidebar"; +import Header from "@/components/dashboard/header/Header"; +import { Separator } from "@/components/ui/separator"; +import { getServerAuthSession } from "@/server/auth"; + +export default async function AdminLayout({ + children, +}: Readonly<{ + children: React.ReactNode; +}>) { + const session = await getServerAuthSession(); + if (!session || session.user.role !== "admin") { + redirect("/"); + } + + return ( + <div> + <Header /> + <div className="flex min-h-[calc(100vh-64px)] w-screen flex-col sm:h-[calc(100vh-64px)] sm:flex-row"> + <div className="hidden flex-none sm:flex"> + <AdminSidebar /> + </div> + <main className="flex-1 bg-muted sm:overflow-y-auto"> + <div className="block w-full sm:hidden"> + <MobileAdminSidebar /> + <Separator /> + </div> + <div className="min-h-30 container flex flex-col gap-1 p-4"> + <AdminNotices /> + <AdminCard>{children}</AdminCard> + </div> + </main> + </div> + </div> + ); +} |
