From d6dd76021226802adf5295b3243d6f2ae4fa5cc2 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Sun, 10 Mar 2024 17:59:58 +0000 Subject: refactor: Move all components to the top level directory --- .../[bookmarkId]/components/BookmarkPreview.tsx | 101 --------------------- .../app/dashboard/preview/[bookmarkId]/page.tsx | 2 +- 2 files changed, 1 insertion(+), 102 deletions(-) delete mode 100644 packages/web/app/dashboard/preview/[bookmarkId]/components/BookmarkPreview.tsx (limited to 'packages/web/app/dashboard/preview') diff --git a/packages/web/app/dashboard/preview/[bookmarkId]/components/BookmarkPreview.tsx b/packages/web/app/dashboard/preview/[bookmarkId]/components/BookmarkPreview.tsx deleted file mode 100644 index 2a8ae1b1..00000000 --- a/packages/web/app/dashboard/preview/[bookmarkId]/components/BookmarkPreview.tsx +++ /dev/null @@ -1,101 +0,0 @@ -"use client"; - -import { BackButton } from "@/components/ui/back-button"; -import { Skeleton } from "@/components/ui/skeleton"; -import { isBookmarkStillCrawling } from "@/lib/bookmarkUtils"; -import { api } from "@/lib/trpc"; -import { ZBookmark } from "@hoarder/trpc/types/bookmarks"; -import { ArrowLeftCircle, CalendarDays, ExternalLink } from "lucide-react"; -import Link from "next/link"; -import Markdown from "react-markdown"; - -export default function BookmarkPreview({ - initialData, -}: { - initialData: ZBookmark; -}) { - const { data: bookmark } = api.bookmarks.getBookmark.useQuery( - { - bookmarkId: initialData.id, - }, - { - initialData, - refetchInterval: (query) => { - const data = query.state.data; - if (!data) { - return false; - } - // If the link is not crawled or not tagged - if (isBookmarkStillCrawling(data)) { - return 1000; - } - return false; - }, - }, - ); - - const linkHeader = bookmark.content.type == "link" && ( -
-

- {bookmark.content.title || bookmark.content.url} -

- - View Original - - -
- ); - - let content; - switch (bookmark.content.type) { - case "link": { - if (!bookmark.content.htmlContent) { - content = ( -
Failed to fetch link content ...
- ); - } else { - content = ( -
- ); - } - break; - } - case "text": { - content = {bookmark.content.text}; - break; - } - } - - return ( -
-
- - - -
- - {bookmark.createdAt.toLocaleString()} - -
-
-
- {linkHeader} -
- {isBookmarkStillCrawling(bookmark) ? ( -
- - - -
- ) : ( - content - )} -
-
- ); -} diff --git a/packages/web/app/dashboard/preview/[bookmarkId]/page.tsx b/packages/web/app/dashboard/preview/[bookmarkId]/page.tsx index 47aeb891..707d2b69 100644 --- a/packages/web/app/dashboard/preview/[bookmarkId]/page.tsx +++ b/packages/web/app/dashboard/preview/[bookmarkId]/page.tsx @@ -1,5 +1,5 @@ import { api } from "@/server/api/client"; -import BookmarkPreview from "./components/BookmarkPreview"; +import BookmarkPreview from "@/components/dashboard/bookmarks/BookmarkPreview"; export default async function BookmarkPreviewPage({ params, -- cgit v1.2.3-70-g09d2