From f476fca758bb039f9605488b61ba35fc097d6cfc Mon Sep 17 00:00:00 2001 From: Nicole Li <40200356+lexafaxine@users.noreply.github.com> Date: Tue, 31 Dec 2024 19:33:41 +0900 Subject: feat: Add delete bookmark confirmation dialog. Fixes #776 (#787) --- .../web/components/dashboard/preview/ActionBar.tsx | 37 +++++++++------------- 1 file changed, 15 insertions(+), 22 deletions(-) (limited to 'apps/web/components/dashboard/preview/ActionBar.tsx') diff --git a/apps/web/components/dashboard/preview/ActionBar.tsx b/apps/web/components/dashboard/preview/ActionBar.tsx index 38ad8fa2..86c86d5a 100644 --- a/apps/web/components/dashboard/preview/ActionBar.tsx +++ b/apps/web/components/dashboard/preview/ActionBar.tsx @@ -1,5 +1,6 @@ -import { useRouter } from "next/navigation"; +import { useState } from "react"; import { ActionButton } from "@/components/ui/action-button"; +import { Button } from "@/components/ui/button"; import { Tooltip, TooltipContent, @@ -10,16 +11,16 @@ import { useTranslation } from "@/lib/i18n/client"; import { Trash2 } from "lucide-react"; import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; -import { - useDeleteBookmark, - useUpdateBookmark, -} from "@hoarder/shared-react/hooks/bookmarks"; +import { useUpdateBookmark } from "@hoarder/shared-react/hooks/bookmarks"; +import DeleteBookmarkConfirmationDialog from "../bookmarks/DeleteBookmarkConfirmationDialog"; import { ArchivedActionIcon, FavouritedActionIcon } from "../bookmarks/icons"; export default function ActionBar({ bookmark }: { bookmark: ZBookmark }) { const { t } = useTranslation(); - const router = useRouter(); + const [deleteBookmarkDialogOpen, setDeleteBookmarkDialogOpen] = + useState(false); + const onError = () => { toast({ variant: "destructive", @@ -44,16 +45,6 @@ export default function ActionBar({ bookmark }: { bookmark: ZBookmark }) { }, onError, }); - const { mutate: deleteBookmark, isPending: pendingDeletion } = - useDeleteBookmark({ - onSuccess: () => { - toast({ - description: "The bookmark has been deleted!", - }); - router.back(); - }, - onError, - }); return (