Skip to content

Commit

Permalink
fix: need userId
Browse files Browse the repository at this point in the history
  • Loading branch information
IanKrieger committed Aug 17, 2023
1 parent 5f88fc2 commit 0554369
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/Campaigns/CloneCampaign.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

Expand Down Expand Up @@ -94,7 +96,7 @@ export function CloneCampaign({ campaignFragment, useChip }: Props) {
if (campaignFragment) {
copyCampaign({
variables: {
input: createCampaignFromFragment(campaignFragment),
input: createCampaignFromFragment(campaignFragment, userId),
},
});
} else {
Expand Down
2 changes: 2 additions & 0 deletions src/form/fragmentUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import { AdSetFragment } from "graphql/ad-set.generated";

export function createCampaignFromFragment(
data: CampaignFragment,
userId: string,
): CreateCampaignInput {
const adSets: CreateAdSetInput[] = data.adSets.map((adSet) =>
createAdSetFromFragment(adSet),
);

const two = moment().utc().add(3, "days");
return {
userId,
adSets: adSets && adSets.length > 0 ? adSets : undefined,
advertiserId: data.advertiser.id,
budget: data.budget,
Expand Down

0 comments on commit 0554369

Please sign in to comment.