import {
  useDeleteShippingOptionTypeAction
} from "./chunk-34I4QIBD.js";
import {
  SingleColumnPage
} from "./chunk-H6MYB7GB.js";
import {
  SingleColumnPageSkeleton
} from "./chunk-INNFZYX2.js";
import {
  ActionMenu
} from "./chunk-BDGZ4EQO.js";
import {
  useShippingOptionType
} from "./chunk-PBQ5M44A.js";

// src/pages/shipping-option-types/shipping-option-type-detail/shipping-option-type-detail.tsx
import { Children } from "react";
import { useLoaderData, useParams } from "react-router-dom";

// src/pages/shipping-option-types/shipping-option-type-detail/components/shipping-option-type-general-section/shipping-option-type-general-section.tsx
import { PencilSquare, Trash } from "@medusajs/icons";
import { Container, Heading, Text } from "@medusajs/ui";
import { useTranslation } from "react-i18next";
import { jsx, jsxs } from "react/jsx-runtime";
var ShippingOptionTypeGeneralSection = ({
  shippingOptionType
}) => {
  const { t } = useTranslation();
  const handleDelete = useDeleteShippingOptionTypeAction(
    shippingOptionType.id,
    shippingOptionType.label
  );
  return /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", "data-testid": "shipping-option-type-general-section-container", children: [
    /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between  px-6 py-4", "data-testid": "shipping-option-type-general-section-header", children: [
      /* @__PURE__ */ jsx(Heading, { "data-testid": "shipping-option-type-general-section-heading", children: shippingOptionType.label }),
      /* @__PURE__ */ jsx(
        ActionMenu,
        {
          groups: [
            {
              actions: [
                {
                  label: t("actions.edit"),
                  icon: /* @__PURE__ */ jsx(PencilSquare, {}),
                  to: "edit"
                }
              ]
            },
            {
              actions: [
                {
                  label: t("actions.delete"),
                  icon: /* @__PURE__ */ jsx(Trash, {}),
                  onClick: handleDelete
                }
              ]
            }
          ],
          "data-testid": "shipping-option-type-general-section-action-menu"
        }
      )
    ] }),
    /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4", "data-testid": "shipping-option-type-general-section-code-row", children: [
      /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", weight: "plus", "data-testid": "shipping-option-type-general-section-code-label", children: t("fields.code") }),
      /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", "data-testid": "shipping-option-type-general-section-code-value", children: shippingOptionType.code })
    ] }),
    /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4", "data-testid": "shipping-option-type-general-section-description-row", children: [
      /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", weight: "plus", "data-testid": "shipping-option-type-general-section-description-label", children: t("fields.description") }),
      /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", "data-testid": "shipping-option-type-general-section-description-value", children: shippingOptionType.description || "-" })
    ] })
  ] });
};

// src/pages/shipping-option-types/shipping-option-type-detail/shipping-option-type-detail.tsx
import { jsx as jsx2 } from "react/jsx-runtime";
var Root = ({ children }) => {
  const { id } = useParams();
  const initialData = useLoaderData();
  const { shipping_option_type, isPending, isError, error } = useShippingOptionType(id, void 0, {
    initialData
  });
  if (isPending || !shipping_option_type) {
    return /* @__PURE__ */ jsx2(SingleColumnPageSkeleton, { sections: 2, showJSON: true, showMetadata: true });
  }
  if (isError) {
    throw error;
  }
  return Children.count(children) > 0 ? /* @__PURE__ */ jsx2(SingleColumnPage, { showJSON: true, showMetadata: true, data: shipping_option_type, children }) : /* @__PURE__ */ jsx2(SingleColumnPage, { showJSON: true, showMetadata: true, data: shipping_option_type, children: /* @__PURE__ */ jsx2(
    ShippingOptionTypeGeneralSection,
    {
      shippingOptionType: shipping_option_type
    }
  ) });
};
var ShippingOptionTypeDetailPage = Object.assign(Root, {
  GeneralSection: ShippingOptionTypeGeneralSection
});

export {
  ShippingOptionTypeDetailPage
};
