diff options
| author | Mohamed Bassem <me@mbassem.com> | 2024-12-30 12:15:35 +0000 |
|---|---|---|
| committer | Mohamed Bassem <me@mbassem.com> | 2024-12-30 12:15:35 +0000 |
| commit | 5902664658a36e4afc81327eea9f8eef05561bcb (patch) | |
| tree | b72415e988efb5cd95e4a28634b0b53bf125b168 /apps/web/app/admin | |
| parent | 179f00b15525b024b6823088ef8fb94b7106b4f0 (diff) | |
| download | karakeep-5902664658a36e4afc81327eea9f8eef05561bcb.tar.zst | |
refactor: Refactor sidebar into a shared component
Diffstat (limited to 'apps/web/app/admin')
| -rw-r--r-- | apps/web/app/admin/layout.tsx | 63 |
1 files changed, 42 insertions, 21 deletions
diff --git a/apps/web/app/admin/layout.tsx b/apps/web/app/admin/layout.tsx index 0d876736..7b20b7ad 100644 --- a/apps/web/app/admin/layout.tsx +++ b/apps/web/app/admin/layout.tsx @@ -1,11 +1,41 @@ 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 MobileSidebar from "@/components/shared/sidebar/MobileSidebar"; +import Sidebar from "@/components/shared/sidebar/Sidebar"; +import SidebarLayout from "@/components/shared/sidebar/SidebarLayout"; import { getServerAuthSession } from "@/server/auth"; +import { TFunction } from "i18next"; +import { Activity, ArrowLeft, Settings, Users } from "lucide-react"; + +const adminSidebarItems = ( + t: TFunction, +): { + name: string; + icon: JSX.Element; + path: string; +}[] => [ + { + name: t("settings.back_to_app"), + icon: <ArrowLeft size={18} />, + path: "/dashboard/bookmarks", + }, + { + name: t("admin.server_stats.server_stats"), + icon: <Activity size={18} />, + path: "/admin/overview", + }, + { + name: t("admin.users_list.users_list"), + icon: <Users size={18} />, + path: "/admin/users", + }, + { + name: t("common.actions"), + icon: <Settings size={18} />, + path: "/admin/actions", + }, +]; export default async function AdminLayout({ children, @@ -18,23 +48,14 @@ export default async function AdminLayout({ } 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> + <SidebarLayout + sidebar={<Sidebar items={adminSidebarItems} />} + mobileSidebar={<MobileSidebar items={adminSidebarItems} />} + > + <div className="flex flex-col gap-1"> + <AdminNotices /> + <AdminCard>{children}</AdminCard> </div> - </div> + </SidebarLayout> ); } |
