"use client"; import React, { useState } from "react"; import { Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, Button, Alert, } from "@nextui-org/react"; import { useTranslation } from "@/shared/lib/useTranslation"; interface DeleteServerModalProps { isOpen: boolean; onClose: () => void; onConfirm: () => void | Promise; title?: string | React.ReactNode; description?: string | React.ReactNode; alertDescription?: string; customAlertContent?: React.ReactNode; } export const DeleteServerModal: React.FC = ({ isOpen, onClose, onConfirm, title, description, alertDescription, customAlertContent, }) => { const { t } = useTranslation(); const [isLoading, setIsLoading] = useState(false); const handleConfirm = async () => { setIsLoading(true); try { await onConfirm(); } finally { setIsLoading(false); } }; const defaultTitle = t("Confirm Delete"); const defaultDescription = t("Are you sure you want to delete this item? This action cannot be undone."); const defaultAlertDescription= t("This action cannot be undone."); return ( {() => ( <> {title || defaultTitle}
{/* Description */}
{description || defaultDescription}
{/* Warning message */} {customAlertContent && customAlertContent}
)}
); }; export default DeleteServerModal;