aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web/app/dashboard/layout.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'apps/web/app/dashboard/layout.tsx')
-rw-r--r--apps/web/app/dashboard/layout.tsx89
1 files changed, 66 insertions, 23 deletions
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: <Home size={18} />,
+ path: "/dashboard/bookmarks",
+ },
+ serverConfig.meilisearch
+ ? [
+ {
+ name: t("common.search"),
+ icon: <Search size={18} />,
+ path: "/dashboard/search",
+ },
+ ]
+ : [],
+ {
+ name: t("common.tags"),
+ icon: <Tag size={18} />,
+ path: "/dashboard/tags",
+ },
+ {
+ name: t("common.highlights"),
+ icon: <Highlighter size={18} />,
+ path: "/dashboard/highlights",
+ },
+ {
+ name: t("common.archive"),
+ icon: <Archive size={18} />,
+ path: "/dashboard/archive",
+ },
+ ].flat();
+
return (
- <div>
- <Header />
- <div className="flex min-h-[calc(100vh-64px)] w-screen flex-col sm:h-[calc(100vh-64px)] sm:flex-row">
- <ValidAccountCheck />
- <div className="hidden flex-none sm:flex">
- <Sidebar />
- </div>
- <main className="flex-1 bg-muted sm:overflow-y-auto">
- {serverConfig.demoMode && <DemoModeBanner />}
- <div className="block w-full sm:hidden">
- <MobileSidebar />
- <Separator />
- </div>
- {modal}
- <div className="min-h-30 container p-4">{children}</div>
- </main>
- </div>
- </div>
+ <SidebarLayout
+ sidebar={
+ <Sidebar
+ items={items}
+ extraSections={
+ <>
+ <Separator />
+ <AllLists initialData={lists} />
+ </>
+ }
+ />
+ }
+ mobileSidebar={<MobileSidebar items={items} />}
+ modal={modal}
+ >
+ {children}
+ </SidebarLayout>
);
}