From 5902664658a36e4afc81327eea9f8eef05561bcb Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Mon, 30 Dec 2024 12:15:35 +0000 Subject: refactor: Refactor sidebar into a shared component --- apps/web/app/dashboard/layout.tsx | 89 +++++++++++++++++++++++++++++---------- 1 file changed, 66 insertions(+), 23 deletions(-) (limited to 'apps/web/app/dashboard') diff --git a/apps/web/app/dashboard/layout.tsx b/apps/web/app/dashboard/layout.tsx index cbd51245..17a7c144 100644 --- a/apps/web/app/dashboard/layout.tsx +++ b/apps/web/app/dashboard/layout.tsx @@ -1,9 +1,13 @@ -import Header from "@/components/dashboard/header/Header"; -import MobileSidebar from "@/components/dashboard/sidebar/ModileSidebar"; -import Sidebar from "@/components/dashboard/sidebar/Sidebar"; -import DemoModeBanner from "@/components/DemoModeBanner"; +import { redirect } from "next/navigation"; +import AllLists from "@/components/dashboard/sidebar/AllLists"; +import MobileSidebar from "@/components/shared/sidebar/MobileSidebar"; +import Sidebar from "@/components/shared/sidebar/Sidebar"; +import SidebarLayout from "@/components/shared/sidebar/SidebarLayout"; import { Separator } from "@/components/ui/separator"; -import ValidAccountCheck from "@/components/utils/ValidAccountCheck"; +import { api } from "@/server/api/client"; +import { getServerAuthSession } from "@/server/auth"; +import { TFunction } from "i18next"; +import { Archive, Highlighter, Home, Search, Tag } from "lucide-react"; import serverConfig from "@hoarder/shared/config"; @@ -14,24 +18,63 @@ export default async function Dashboard({ children: React.ReactNode; modal: React.ReactNode; }>) { + const session = await getServerAuthSession(); + if (!session) { + redirect("/"); + } + + const lists = await api.lists.list(); + + const items = (t: TFunction) => + [ + { + name: t("common.home"), + icon: , + path: "/dashboard/bookmarks", + }, + serverConfig.meilisearch + ? [ + { + name: t("common.search"), + icon: , + path: "/dashboard/search", + }, + ] + : [], + { + name: t("common.tags"), + icon: , + path: "/dashboard/tags", + }, + { + name: t("common.highlights"), + icon: , + path: "/dashboard/highlights", + }, + { + name: t("common.archive"), + icon: , + path: "/dashboard/archive", + }, + ].flat(); + return ( -
-
-
- -
- -
-
- {serverConfig.demoMode && } -
- - -
- {modal} -
{children}
-
-
-
+ + + + + } + /> + } + mobileSidebar={} + modal={modal} + > + {children} + ); } -- cgit v1.2.3-70-g09d2