import {
  AddCampaignPromotionForm
} from "./chunk-DRKRLQZZ.js";
import "./chunk-SFQOECF7.js";
import "./chunk-IQPN4PZJ.js";
import "./chunk-TKGWSUEI.js";
import "./chunk-SITRHMZZ.js";
import {
  RouteDrawer
} from "./chunk-GDWBOQI5.js";
import "./chunk-3QSRE5LS.js";
import {
  useCampaigns,
  usePromotion
} from "./chunk-MR6REQKT.js";
import "./chunk-W34KDYZA.js";
import "./chunk-RHKRREUU.js";
import "./chunk-ZA2KFUFR.js";
import "./chunk-DTGEFKK4.js";
import "./chunk-NBMM2TZK.js";

// src/pages/promotions/[id]/add-to-campaign/index.tsx
import { Heading } from "@medusajs/ui";
import { useTranslation } from "react-i18next";
import { useParams } from "react-router-dom";
import { jsx, jsxs } from "react/jsx-runtime";
var Component = () => {
  const { id } = useParams();
  const { t } = useTranslation();
  const { promotion, isPending, isError, error } = usePromotion(id);
  let campaignQuery = {};
  if (promotion?.application_method?.currency_code) {
    campaignQuery = { budget: { currency_code: promotion?.application_method?.currency_code } };
  }
  const { campaigns, isPending: areCampaignsLoading, isError: isCampaignError, error: campaignError } = useCampaigns(campaignQuery);
  if (isError || isCampaignError) throw error || campaignError;
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
    /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(Heading, { children: t("promotions.campaign.edit.header") }) }),
    !isPending && !areCampaignsLoading && promotion && campaigns && /* @__PURE__ */ jsx(AddCampaignPromotionForm, { promotion, campaigns })
  ] });
};
export {
  Component
};
