aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web/components/dashboard/preview/AssetContentSection.tsx
blob: 3fbbc51927acf98ba0f1d26c858a6e85b5e36964 (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
import Image from "next/image";

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

export function AssetContentSection({ bookmark }: { bookmark: ZBookmark }) {
  if (bookmark.content.type != "asset") {
    throw new Error("Invalid content type");
  }

  let content;
  switch (bookmark.content.assetType) {
    case "image": {
      switch (bookmark.content.assetType) {
        case "image": {
          content = (
            <div className="relative h-full min-w-full">
              <Image
                alt="asset"
                fill={true}
                className="object-contain"
                src={`/api/assets/${bookmark.content.assetId}`}
              />
            </div>
          );
        }
      }
      break;
    }
  }
  return content;
}