Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
added alert dialog before remove
Ashish Viradiyafa395e552d03
diff --git a/components/agreements/agreement-card.tsx b/components/agreements/agreement-card.tsxindex f5333e61..51bf69f6 100644--- a/components/agreements/agreement-card.tsx+++ b/components/agreements/agreement-card.tsx@@ -1,8 +1,19 @@+import { useState } from "react";import { useTeam } from "@/context/team-context";import { FileTextIcon, MoreVertical, TrashIcon } from "lucide-react";import { toast } from "sonner";+import {+ AlertDialog,+ AlertDialogAction,+ AlertDialogCancel,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogFooter,+ AlertDialogHeader,+ AlertDialogTitle,+} from "@/components/ui/alert-dialog";import { Button } from "@/components/ui/button";import {DropdownMenu,@@ -29,6 +40,7 @@ export default function AgreementCard({onDelete,}: AgreementCardProps) {const teamInfo = useTeam();+ const [showDeleteDialog, setShowDeleteDialog] = useState(false);const handleDelete = async () => {toast.promise(@@ -52,36 +64,66 @@ export default function AgreementCard({};return (- <div className="flex items-center justify-between rounded-lg border p-4">- <div className="flex items-center space-x-4">- <div className="flex h-10 w-10 items-center justify-center rounded-lg bg-muted">- <FileTextIcon className="h-5 w-5" />- </div>- <div>- <h3 className="font-medium">{agreement.name}</h3>- <p className="text-sm text-muted-foreground">- Last updated {new Date(agreement.updatedAt).toLocaleDateString()}- </p>+ <>+ <div className="flex items-center justify-between rounded-lg border p-4">+ <div className="flex items-center space-x-4">+ <div className="flex h-10 w-10 items-center justify-center rounded-lg bg-muted">+ <FileTextIcon className="h-5 w-5" />+ </div>+ <div>+ <h3 className="font-medium">{agreement.name}</h3>+ <p className="text-sm text-muted-foreground">+ Last updated {new Date(agreement.updatedAt).toLocaleDateString()}+ </p>+ </div></div>++ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button variant="ghost" className="h-8 w-8 p-0">+ <span className="sr-only">Open menu</span>+ <MoreVertical className="h-4 w-4" />+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end">+ <DropdownMenuItem+ className="text-destructive focus:bg-destructive focus:text-destructive-foreground"+ onClick={() => setShowDeleteDialog(true)}+ >+ <TrashIcon className="mr-2 h-4 w-4" />+ Delete agreement+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu></div>- <DropdownMenu>- <DropdownMenuTrigger asChild>- <Button variant="ghost" className="h-8 w-8 p-0">- <span className="sr-only">Open menu</span>- <MoreVertical className="h-4 w-4" />- </Button>- </DropdownMenuTrigger>- <DropdownMenuContent align="end">- <DropdownMenuItem- className="text-destructive focus:bg-destructive focus:text-destructive-foreground"- onClick={handleDelete}- >- <TrashIcon className="mr-2 h-4 w-4" />- Delete agreement- </DropdownMenuItem>- </DropdownMenuContent>- </DropdownMenu>- </div>+ <AlertDialog open={showDeleteDialog} onOpenChange={setShowDeleteDialog}>+ <AlertDialogContent>+ <AlertDialogHeader>+ <AlertDialogTitle>Are you sure?</AlertDialogTitle>+ <AlertDialogDescription>+ This will permanently delete the NDA agreement "{agreement.name}".+ This action cannot be undone.+ <br />+ <br />+ <span className="font-medium">+ Note: If this agreement is still referenced in any documents or+ dataroom links, it will remain available there until those+ references are removed.+ </span>+ </AlertDialogDescription>+ </AlertDialogHeader>+ <AlertDialogFooter>+ <AlertDialogCancel>Cancel</AlertDialogCancel>+ <AlertDialogAction+ onClick={handleDelete}+ className="bg-destructive text-destructive-foreground"+ >+ Delete+ </AlertDialogAction>+ </AlertDialogFooter>+ </AlertDialogContent>+ </AlertDialog>+ </>);}diff --git a/components/ui/alert-dialog.tsx b/components/ui/alert-dialog.tsxnew file mode 100644index 00000000..7ef4e75a--- /dev/null+++ b/components/ui/alert-dialog.tsx@@ -0,0 +1,141 @@+import * as React from "react";++import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";++import { cn } from "@/lib/utils";++import { buttonVariants } from "@/components/ui/button";++const AlertDialog = AlertDialogPrimitive.Root;++const AlertDialogTrigger = AlertDialogPrimitive.Trigger;++const AlertDialogPortal = AlertDialogPrimitive.Portal;++const AlertDialogOverlay = React.forwardRef<+ React.ElementRef<typeof AlertDialogPrimitive.Overlay>,+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>+>(({ className, ...props }, ref) => (+ <AlertDialogPrimitive.Overlay+ className={cn(+ "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",+ className,+ )}+ {...props}+ ref={ref}+ />+));+AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;++const AlertDialogContent = React.forwardRef<+ React.ElementRef<typeof AlertDialogPrimitive.Content>,+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>+>(({ className, ...props }, ref) => (+ <AlertDialogPortal>+ <AlertDialogOverlay />+ <AlertDialogPrimitive.Content+ ref={ref}+ className={cn(+ "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",+ className,+ )}+ {...props}+ />+ </AlertDialogPortal>+));+AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;++const AlertDialogHeader = ({+ className,+ ...props+}: React.HTMLAttributes<HTMLDivElement>) => (+ <div+ className={cn(+ "flex flex-col space-y-2 text-center sm:text-left",+ className,+ )}+ {...props}+ />+);+AlertDialogHeader.displayName = "AlertDialogHeader";++const AlertDialogFooter = ({+ className,+ ...props+}: React.HTMLAttributes<HTMLDivElement>) => (+ <div+ className={cn(+ "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",+ className,+ )}+ {...props}+ />+);+AlertDialogFooter.displayName = "AlertDialogFooter";++const AlertDialogTitle = React.forwardRef<+ React.ElementRef<typeof AlertDialogPrimitive.Title>,+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>+>(({ className, ...props }, ref) => (+ <AlertDialogPrimitive.Title+ ref={ref}+ className={cn("text-lg font-semibold", className)}+ {...props}+ />+));+AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;++const AlertDialogDescription = React.forwardRef<+ React.ElementRef<typeof AlertDialogPrimitive.Description>,+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>+>(({ className, ...props }, ref) => (+ <AlertDialogPrimitive.Description+ ref={ref}+ className={cn("text-sm text-muted-foreground", className)}+ {...props}+ />+));+AlertDialogDescription.displayName =+ AlertDialogPrimitive.Description.displayName;++const AlertDialogAction = React.forwardRef<+ React.ElementRef<typeof AlertDialogPrimitive.Action>,+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>+>(({ className, ...props }, ref) => (+ <AlertDialogPrimitive.Action+ ref={ref}+ className={cn(buttonVariants(), className)}+ {...props}+ />+));+AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;++const AlertDialogCancel = React.forwardRef<+ React.ElementRef<typeof AlertDialogPrimitive.Cancel>,+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>+>(({ className, ...props }, ref) => (+ <AlertDialogPrimitive.Cancel+ ref={ref}+ className={cn(+ buttonVariants({ variant: "outline" }),+ "mt-2 sm:mt-0",+ className,+ )}+ {...props}+ />+));+AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;++export {+ AlertDialog,+ AlertDialogPortal,+ AlertDialogOverlay,+ AlertDialogTrigger,+ AlertDialogContent,+ AlertDialogHeader,+ AlertDialogFooter,+ AlertDialogTitle,+ AlertDialogDescription,+ AlertDialogAction,+ AlertDialogCancel,+};diff --git a/package.json b/package.jsonindex 8b78043a..b0a1d5d9 100644--- a/package.json+++ b/package.json@@ -35,6 +35,7 @@"@pdf-lib/fontkit": "^1.1.1","@prisma/client": "^6.5.0","@radix-ui/react-accordion": "^1.2.4",+ "@radix-ui/react-alert-dialog": "^1.1.13","@radix-ui/react-avatar": "^1.1.4","@radix-ui/react-checkbox": "^1.1.5","@radix-ui/react-collapsible": "^1.1.4",