aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web/components/dashboard/sidebar/Sidebar.tsx
blob: 13260e07ef66bb5be79e0c10c38d9520254a363e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { redirect } from "next/navigation";
import { Separator } from "@/components/ui/separator";
import { api } from "@/server/api/client";
import { getServerAuthSession } from "@/server/auth";
import { Archive, Home, Search, Tag } from "lucide-react";

import serverConfig from "@hoarder/shared/config";

import AllLists from "./AllLists";
import SidebarItem from "./SidebarItem";

export default async function Sidebar() {
  const session = await getServerAuthSession();
  if (!session) {
    redirect("/");
  }

  const lists = await api.lists.list();

  const searchItem = serverConfig.meilisearch
    ? [
        {
          name: "Search",
          icon: <Search size={18} />,
          path: "/dashboard/search",
        },
      ]
    : [];

  const menu: {
    name: string;
    icon: JSX.Element;
    path: string;
  }[] = [
    {
      name: "Home",
      icon: <Home size={18} />,
      path: "/dashboard/bookmarks",
    },
    ...searchItem,
    {
      name: "Tags",
      icon: <Tag size={18} />,
      path: "/dashboard/tags",
    },
    {
      name: "Archive",
      icon: <Archive size={18} />,
      path: "/dashboard/archive",
    },
  ];

  return (
    <aside className="flex h-[calc(100vh-64px)] w-60 flex-col gap-5 border-r p-4 ">
      <div>
        <ul className="space-y-2 text-sm font-medium">
          {menu.map((item) => (
            <SidebarItem
              key={item.name}
              logo={item.icon}
              name={item.name}
              path={item.path}
            />
          ))}
        </ul>
      </div>
      <Separator />
      <AllLists initialData={lists} />
      <div className="mt-auto flex items-center border-t pt-2">
        Hoarder v{serverConfig.serverVersion}
      </div>
    </aside>
  );
}