"use client"; import { useToast } from "@/components/ui/use-toast"; import { api } from "@/lib/trpc"; import { ZBookmark, ZUpdateBookmarksRequest } from "@/lib/types/api/bookmarks"; import { useRouter } from "next/navigation"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Archive, MoreHorizontal, Star, Trash2 } from "lucide-react"; export default function BookmarkOptions({ bookmark }: { bookmark: ZBookmark }) { const { toast } = useToast(); const router = useRouter(); const linkId = bookmark.id; const unbookmarkLink = async () => { try { await api.bookmarks.deleteBookmark.mutate({ bookmarkId: linkId, }); toast({ description: "The bookmark has been deleted!", }); } catch (e) { toast({ variant: "destructive", title: "Something went wrong", description: "There was a problem with your request.", }); } router.refresh(); }; const updateBookmark = async (req: ZUpdateBookmarksRequest) => { try { await api.bookmarks.updateBookmark.mutate(req); toast({ description: "The bookmark has been updated!", }); } catch (e) { toast({ variant: "destructive", title: "Something went wrong", description: "There was a problem with your request.", }); } router.refresh(); }; return ( updateBookmark({ bookmarkId: linkId, favourited: !bookmark.favourited, }) } > {bookmark.favourited ? "Un-favourite" : "Favourite"} updateBookmark({ bookmarkId: linkId, archived: !bookmark.archived }) } > {bookmark.archived ? "Un-archive" : "Archive"} Delete ); }