"use client" import * as React from "react" import { type Row } from "@tanstack/react-table" import { Loader, Trash } from "lucide-react" import { toast } from "sonner" import { useMediaQuery } from "@/hooks/use-media-query" import { Button } from "@/components/ui/button" import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog" import { Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger, } from "@/components/ui/drawer" import { removeTags } from "@/lib//tags-plant/service" import { Tag } from "@/db/schema/vendorData" interface DeleteTasksDialogProps extends React.ComponentPropsWithoutRef { tags: Row["original"][] showTrigger?: boolean projectCode: string packageCode: string onSuccess?: () => void } export function DeleteTagsDialog({ tags, showTrigger = true, onSuccess, projectCode, packageCode, ...props }: DeleteTasksDialogProps) { const [isDeletePending, startDeleteTransition] = React.useTransition() const isDesktop = useMediaQuery("(min-width: 640px)") function onDelete() { startDeleteTransition(async () => { const { error } = await removeTags({ ids: tags.map((tag) => tag.id),projectCode, packageCode }) if (error) { toast.error(error) return } props.onOpenChange?.(false) toast.success("Tasks deleted") onSuccess?.() }) } if (isDesktop) { return ( {showTrigger ? ( ) : null} Are you absolutely sure? This action cannot be undone. This will permanently delete your{" "} {tags.length} {tags.length === 1 ? " tag" : " tags"} from our servers. ) } return ( {showTrigger ? ( ) : null} Are you absolutely sure? This action cannot be undone. This will permanently delete your{" "} {tags.length} {tags.length === 1 ? " tag" : " tags"} from our servers. ) }