"use client"; import React from "react"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "./ui/dialog"; import { Button } from "./ui/button"; import { AlertTriangle } from "lucide-react"; interface DeleteConfirmationDialogProps { open: boolean; onOpenChange: (open: boolean) => void; title?: string; description?: string; confirmText?: string; cancelText?: string; onConfirm: () => void | Promise; isLoading?: boolean; variant?: "destructive" | "default"; } export const DeleteConfirmationDialog: React.FC< DeleteConfirmationDialogProps > = ({ open, onOpenChange, title = "Are you sure?", description = "This action cannot be undone.", confirmText = "Confirm", cancelText = "Cancel", onConfirm, isLoading = false, variant = "destructive", }) => { const handleConfirm = async () => { try { await onConfirm(); } finally { // Only close if not in loading state (let the parent handle this) if (!isLoading) { onOpenChange(false); } } }; return (
{variant === "destructive" && ( )} {title}
{description}
); };