import {
  useDeleteShippingOptionType
} from "./chunk-OW2UL5FI.mjs";

// src/routes/shipping-option-types/common/hooks/use-delete-shipping-option-type-action.tsx
import { useNavigate } from "react-router-dom";
import { toast, usePrompt } from "@medusajs/ui";
import { useTranslation } from "react-i18next";
var useDeleteShippingOptionTypeAction = (id, label) => {
  const { t } = useTranslation();
  const prompt = usePrompt();
  const navigate = useNavigate();
  const { mutateAsync } = useDeleteShippingOptionType(id);
  const handleDelete = async () => {
    const result = await prompt({
      title: t("general.areYouSure"),
      description: t("shippingOptionTypes.delete.confirmation", { label }),
      confirmText: t("actions.delete"),
      cancelText: t("actions.cancel")
    });
    if (!result) {
      return;
    }
    await mutateAsync(void 0, {
      onSuccess: () => {
        navigate("/settings/locations/shipping-option-types", {
          replace: true
        });
        toast.success(t("shippingOptionTypes.delete.successToast", { label }));
      },
      onError: (e) => {
        toast.error(e.message);
      }
    });
  };
  return handleDelete;
};

export {
  useDeleteShippingOptionTypeAction
};
