import { jsx as _jsx } from "react/jsx-runtime";
import { ConnectDeleteDriveModal, toast } from "@powerhousedao/design-system";
import { closePHModal, deleteDrive, setSelectedDrive, useDriveById, useDrives, usePHModal, } from "@powerhousedao/reactor-browser";
import { useTranslation } from "react-i18next";
export const DeleteDriveModal = () => {
    const phModal = usePHModal();
    const open = phModal?.type === "deleteDrive";
    const driveId = open ? phModal.driveId : undefined;
    const [drive] = useDriveById(driveId);
    const drives = useDrives();
    if (!drive) {
        return null;
    }
    async function onDeleteDrive() {
        if (!driveId) {
            return;
        }
        await deleteDrive(driveId);
        setSelectedDrive(drives?.[0]);
        closePHModal();
        toast(t("notifications.deleteDriveSuccess"), {
            type: "connect-deleted",
        });
    }
    const { t } = useTranslation();
    return (_jsx(ConnectDeleteDriveModal, { open: open, driveName: drive.header.name, onCancel: closePHModal, header: t("modals.deleteDrive.title", { label: drive.header.name }), body: t("modals.deleteDrive.body"), inputPlaceholder: t("modals.deleteDrive.inputPlaceholder"), cancelLabel: t("common.cancel"), continueLabel: t("common.delete"), onContinue: () => onDeleteDrive(), onOpenChange: (status) => {
            if (!status)
                return closePHModal();
        } }));
};
//# sourceMappingURL=DeleteDriveModal.js.map