import { r as reactExports, j as jsxRuntimeExports, I as Icon, e as usePHModal, O as useDrives, p as useTranslation, i as closePHModal, W as deleteDrive, s as setSelectedDrive, m as toast } from "./index-DEuI3Aoa.js";
import { u as useDriveById } from "./drive-by-id-DG_S24DX.js";
import { C as ConnectConfirmationModal } from "./confirmation-modal-JaOmXglG.js";
import { F as FormInput } from "./form-input-DucXwitU.js";
const ConnectDeleteDriveModal = (props) => {
  const { inputPlaceholder, body, driveName, ...confirmationModalProps } = props;
  const [inputName, setInputName] = reactExports.useState("");
  return jsxRuntimeExports.jsx(ConnectConfirmationModal, { bodyProps: { className: "p-0 bg-white my-0" }, containerProps: { className: "w-[450px]" }, continueButtonProps: {
    disabled: inputName !== driveName,
    className: inputName !== driveName ? "bg-red-600 hover:scale-100 cursor-not-allowed active:opacity-100" : "bg-red-900"
  }, ...confirmationModalProps, children: jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsx("div", { className: "my-6 rounded-md bg-slate-50 p-4 text-center", children: body }), jsxRuntimeExports.jsx("div", { children: jsxRuntimeExports.jsx(FormInput, { hideErrors: true, icon: jsxRuntimeExports.jsx(Icon, { name: "Lock" }), onChange: (e) => setInputName(e.target.value), placeholder: inputPlaceholder, value: inputName }) })] }) });
};
const DeleteDriveModal = () => {
  const phModal = usePHModal();
  const open = phModal?.type === "deleteDrive";
  const driveId = open ? phModal.driveId : void 0;
  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 /* @__PURE__ */ jsxRuntimeExports.jsx(
    ConnectDeleteDriveModal,
    {
      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();
      }
    }
  );
};
export {
  DeleteDriveModal
};
//# sourceMappingURL=DeleteDriveModal-CnaroA19.js.map
