aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web/components/dashboard/bookmarks/Bookmarks.tsx
blob: 96e5c0675a086ef5b4571257e5ea6b2ce6fd66f1 (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
import { redirect } from "next/navigation";
import { api } from "@/server/api/client";
import { getServerAuthSession } from "@/server/auth";

import type { ZGetBookmarksRequest } from "@hoarder/trpc/types/bookmarks";

import BookmarksGrid from "./BookmarksGrid";

export default async function Bookmarks({
  favourited,
  archived,
  title,
  showDivider,
  showEditorCard = false,
}: ZGetBookmarksRequest & {
  title: string;
  showDivider?: boolean;
  showEditorCard?: boolean;
}) {
  const session = await getServerAuthSession();
  if (!session) {
    redirect("/");
  }

  const query = {
    favourited,
    archived,
  };

  const bookmarks = await api.bookmarks.getBookmarks(query);

  return (
    <div className="container flex flex-col gap-3">
      <div className="text-2xl">{title}</div>
      {showDivider && <hr />}
      <BookmarksGrid
        query={query}
        bookmarks={bookmarks}
        showEditorCard={showEditorCard}
      />
    </div>
  );
}