From 7d163f2189c6f8080c0a9185cacab52b1b2cd5c0 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Fri, 26 Apr 2024 12:38:02 +0100 Subject: feature: Allow users to delete all unused tags in one go --- apps/web/components/dashboard/tags/AllTagsView.tsx | 54 ++++++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) (limited to 'apps/web/components/dashboard') diff --git a/apps/web/components/dashboard/tags/AllTagsView.tsx b/apps/web/components/dashboard/tags/AllTagsView.tsx index ce780a2f..a16dd759 100644 --- a/apps/web/components/dashboard/tags/AllTagsView.tsx +++ b/apps/web/components/dashboard/tags/AllTagsView.tsx @@ -1,6 +1,8 @@ "use client"; import Link from "next/link"; +import { ActionButton } from "@/components/ui/action-button"; +import ActionConfirmingDialog from "@/components/ui/action-confirming-dialog"; import { Button } from "@/components/ui/button"; import { Collapsible, @@ -9,13 +11,50 @@ import { } from "@/components/ui/collapsible"; import InfoTooltip from "@/components/ui/info-tooltip"; import { Separator } from "@/components/ui/separator"; +import { toast } from "@/components/ui/use-toast"; import { api } from "@/lib/trpc"; import { X } from "lucide-react"; import type { ZGetTagResponse } from "@hoarder/shared/types/tags"; +import { useDeleteUnusedTags } from "@hoarder/shared-react/hooks/tags"; import DeleteTagConfirmationDialog from "./DeleteTagConfirmationDialog"; +function DeleteAllUnusedTags({ numUnusedTags }: { numUnusedTags: number }) { + const { mutate, isPending } = useDeleteUnusedTags({ + onSuccess: () => { + toast({ + description: `Deleted all ${numUnusedTags} unused tags`, + }); + }, + onError: () => { + toast({ + description: "Something went wrong", + variant: "destructive", + }); + }, + }); + return ( + ( + mutate()} + > + DELETE THEM ALL + + )} + > + + + ); +} + function TagPill({ id, name, @@ -102,9 +141,18 @@ export default function AllTagsView({ - - - +
+ + + + {emptyTags.length > 0 && ( + + )} +
{tagsToPill(emptyTags)}
-- cgit v1.2.3-70-g09d2