import { Button } from "@/components/ui/button"; import { Trash2 } from "lucide-react"; import { useState } from "react"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; interface DeleteButtonProps { onClick: () => void | Promise; loading?: boolean; disabled?: boolean; label?: string; title?: string; description?: string; } export function DeleteButton({ onClick, loading = false, disabled = false, label = "Xóa khỏi server", title = "Xóa khỏi server", description = "Bạn có chắc chắn muốn xóa các phần mềm này khỏi server không? Hành động này không thể hoàn tác.", }: DeleteButtonProps) { const [open, setOpen] = useState(false); const [isConfirming, setIsConfirming] = useState(false); const handleConfirm = async () => { setIsConfirming(true); try { await onClick(); } finally { setIsConfirming(false); setOpen(false); } }; return ( <> {title} {description} ); }