From 05543690173790e90beb96d88237bdbb8cd4354a Mon Sep 17 00:00:00 2001 From: Ian Krieger Date: Thu, 17 Aug 2023 09:55:37 -0400 Subject: [PATCH] fix: need userId --- src/components/Campaigns/CloneCampaign.tsx | 4 +++- src/form/fragmentUtil.ts | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/Campaigns/CloneCampaign.tsx b/src/components/Campaigns/CloneCampaign.tsx index 67d3a4c7..2fad2d29 100644 --- a/src/components/Campaigns/CloneCampaign.tsx +++ b/src/components/Campaigns/CloneCampaign.tsx @@ -19,6 +19,7 @@ import { AdvertiserCampaignsDocument } from "graphql/advertiser.generated"; import { createCampaignFromFragment } from "form/fragmentUtil"; import { useAdvertiser } from "auth/hooks/queries/useAdvertiser"; import ContentCopyIcon from "@mui/icons-material/ContentCopy"; +import { useUser } from "auth/hooks/queries/useUser"; interface Props { campaignFragment?: CampaignFragment | null; @@ -27,6 +28,7 @@ interface Props { export function CloneCampaign({ campaignFragment, useChip }: Props) { const { advertiser } = useAdvertiser(); + const { userId } = useUser(); const history = useHistory(); const [open, setOpen] = useState(false); @@ -94,7 +96,7 @@ export function CloneCampaign({ campaignFragment, useChip }: Props) { if (campaignFragment) { copyCampaign({ variables: { - input: createCampaignFromFragment(campaignFragment), + input: createCampaignFromFragment(campaignFragment, userId), }, }); } else { diff --git a/src/form/fragmentUtil.ts b/src/form/fragmentUtil.ts index b7db3465..ea1f8d9c 100644 --- a/src/form/fragmentUtil.ts +++ b/src/form/fragmentUtil.ts @@ -5,6 +5,7 @@ import { AdSetFragment } from "graphql/ad-set.generated"; export function createCampaignFromFragment( data: CampaignFragment, + userId: string, ): CreateCampaignInput { const adSets: CreateAdSetInput[] = data.adSets.map((adSet) => createAdSetFromFragment(adSet), @@ -12,6 +13,7 @@ export function createCampaignFromFragment( const two = moment().utc().add(3, "days"); return { + userId, adSets: adSets && adSets.length > 0 ? adSets : undefined, advertiserId: data.advertiser.id, budget: data.budget,