From 7400914396eea0c9a1fb7bc59e022babc2186f42 Mon Sep 17 00:00:00 2001
From: MohamedBassem <me@mbassem.com>
Date: Fri, 9 Feb 2024 16:47:17 +0000
Subject: [feature] Add the ability to favourite and archive bookmarks

---
 .../dashboard/bookmarks/components/LinkCard.tsx    | 55 ++--------------------
 1 file changed, 3 insertions(+), 52 deletions(-)

(limited to 'packages/web/app/dashboard/bookmarks/components/LinkCard.tsx')

diff --git a/packages/web/app/dashboard/bookmarks/components/LinkCard.tsx b/packages/web/app/dashboard/bookmarks/components/LinkCard.tsx
index aeef6bae..039cb156 100644
--- a/packages/web/app/dashboard/bookmarks/components/LinkCard.tsx
+++ b/packages/web/app/dashboard/bookmarks/components/LinkCard.tsx
@@ -1,63 +1,14 @@
-"use client";
-
 import { Badge } from "@/components/ui/badge";
-import { Button } from "@/components/ui/button";
-import {
-  DropdownMenu,
-  DropdownMenuContent,
-  DropdownMenuItem,
-  DropdownMenuTrigger,
-} from "@/components/ui/dropdown-menu";
 import {
   ImageCard,
   ImageCardBody,
   ImageCardFooter,
   ImageCardTitle,
 } from "@/components/ui/imageCard";
-import { useToast } from "@/components/ui/use-toast";
-import APIClient from "@/lib/api";
 import { ZBookmark } from "@/lib/types/api/bookmarks";
-import { MoreHorizontal, Trash2 } from "lucide-react";
 import Link from "next/link";
-import { useRouter } from "next/navigation";
-
-export function LinkOptions({ linkId }: { linkId: string }) {
-  const { toast } = useToast();
-  const router = useRouter();
-
-  const unbookmarkLink = async () => {
-    const [_, error] = await APIClient.deleteBookmark(linkId);
+import BookmarkOptions from "./BookmarkOptions";
 
-    if (error) {
-      toast({
-        variant: "destructive",
-        title: "Something went wrong",
-        description: "There was a problem with your request.",
-      });
-    } else {
-      toast({
-        description: "The link has been deleted!",
-      });
-    }
-
-    router.refresh();
-  };
-  return (
-    <DropdownMenu>
-      <DropdownMenuTrigger asChild>
-        <Button variant="ghost">
-          <MoreHorizontal />
-        </Button>
-      </DropdownMenuTrigger>
-      <DropdownMenuContent className="w-fit">
-        <DropdownMenuItem className="text-destructive" onClick={unbookmarkLink}>
-          <Trash2 className="mr-2 size-4" />
-          <span>Delete</span>
-        </DropdownMenuItem>
-      </DropdownMenuContent>
-    </DropdownMenu>
-  );
-}
 
 export default function LinkCard({ bookmark }: { bookmark: ZBookmark }) {
   const link = bookmark.content;
@@ -71,7 +22,7 @@ export default function LinkCard({ bookmark }: { bookmark: ZBookmark }) {
       image={link?.imageUrl ?? undefined}
     >
       <ImageCardTitle>
-        <Link className="line-clamp-3" href={link.url}>
+        <Link className="line-clamp-2" href={link.url}>
           {link?.title ?? parsedUrl.host}
         </Link>
       </ImageCardTitle>
@@ -93,7 +44,7 @@ export default function LinkCard({ bookmark }: { bookmark: ZBookmark }) {
               {parsedUrl.host}
             </Link>
           </div>
-          <LinkOptions linkId={bookmark.id} />
+          <BookmarkOptions bookmark={bookmark} />
         </div>
       </ImageCardFooter>
     </ImageCard>
-- 
cgit v1.2.3-70-g09d2

