1 import { Heading } from "@medusajs/ui"
2 import { useTranslation } from "react-i18next"
3 import { useParams } from "react-router-dom"
4
5 import { RouteDrawer } from "../../../components/modals"
6 import { usePromotion } from "../../../hooks/api/promotions"
7 import { AddCampaignPromotionForm } from "./components/add-campaign-promotion-form"
8
9 export const PromotionAddCampaign = () => {
10 const { id } = useParams()
11 const { t } = useTranslation()
12 const { promotion, isPending, isError, error } = usePromotion(id!)
13
14 if (isError) {
15 throw error
16 }
17
18 return (
19 <RouteDrawer>
20 <RouteDrawer.Header>
21 <Heading>{t("promotions.campaign.edit.header")}</Heading>
22 </RouteDrawer.Header>
23
24 {!isPending && promotion && (
25 <AddCampaignPromotionForm promotion={promotion} />
26 )}
27 </RouteDrawer>
28 )
29 }