From 179f00b15525b024b6823088ef8fb94b7106b4f0 Mon Sep 17 00:00:00 2001
From: Mohamed Bassem <me@mbassem.com>
Date: Mon, 30 Dec 2024 11:27:32 +0000
Subject: feat: Change the admin page to be tabbed similar to that of the
 settings page

---
 apps/web/app/admin/layout.tsx | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 apps/web/app/admin/layout.tsx

(limited to 'apps/web/app/admin/layout.tsx')

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>
+  );
+}
-- 
cgit v1.2.3-70-g09d2

