diff --git a/src/components/Campaigns/CloneCampaign.tsx b/src/components/Campaigns/CloneCampaign.tsx
index 1214878f..a8915a61 100644
--- a/src/components/Campaigns/CloneCampaign.tsx
+++ b/src/components/Campaigns/CloneCampaign.tsx
@@ -25,9 +25,10 @@ import { FilterContext } from "state/context";
interface Props {
campaignFragment?: CampaignFragment | null;
useChip?: boolean;
+ disabled?: boolean;
}
-export function CloneCampaign({ campaignFragment, useChip }: Props) {
+export function CloneCampaign({ campaignFragment, useChip, disabled }: Props) {
const { advertiser } = useAdvertiser();
const { fromDate } = useContext(FilterContext);
const { userId } = useUser();
@@ -62,7 +63,7 @@ export function CloneCampaign({ campaignFragment, useChip }: Props) {
onClick={() => {
setOpen(true);
}}
- disabled={loading || !campaignFragment}
+ disabled={loading || !campaignFragment || disabled}
icon={}
/>
) : (
@@ -74,7 +75,7 @@ export function CloneCampaign({ campaignFragment, useChip }: Props) {
e.preventDefault();
setOpen(true);
}}
- disabled={loading || !campaignFragment}
+ disabled={loading || !campaignFragment || disabled}
startIcon={}
>
Clone Campaign
@@ -84,7 +85,7 @@ export function CloneCampaign({ campaignFragment, useChip }: Props) {
{`Copy campaign: "${campaignFragment?.name}"?`}
- Copying a campaign will take all properties including ad sets and
+ Cloning a campaign will take all properties including ad sets and
ads, and create a new draft campaign with them.
{loading && }
diff --git a/src/user/library/index.test.ts b/src/user/library/index.test.ts
index 254f396c..3aca2f99 100644
--- a/src/user/library/index.test.ts
+++ b/src/user/library/index.test.ts
@@ -161,7 +161,7 @@ describe("pricing logic (read)", () => {
c.adSets = [];
});
const formObject = editCampaignValues(campaign, "abc");
- expect(formObject.price).toEqual(6);
+ expect(formObject.price).toEqual(100);
expect(formObject.billingType).toEqual("cpm");
});
});
diff --git a/src/user/library/index.ts b/src/user/library/index.ts
index e76d387b..3d13df89 100644
--- a/src/user/library/index.ts
+++ b/src/user/library/index.ts
@@ -110,11 +110,14 @@ export function editCampaignValues(
campaign: CampaignFragment,
advertiserId: string,
): CampaignForm {
- const ads: AdFragment[] = _.flatMap(campaign.adSets, "ads");
+ const ads: AdFragment[] = _.filter(
+ _.flatMap(campaign.adSets, "ads"),
+ (a) => a.state !== "deleted",
+ );
const billingType = (_.head(campaign.adSets)?.billingType ??
"cpm") as Billing;
- const rawPrice = BigNumber(_.head(ads)?.price ?? "0.006");
+ const rawPrice = BigNumber(_.head(ads)?.price ?? "0.1");
const price = billingType === "cpm" ? rawPrice.multipliedBy(1000) : rawPrice;
return {
diff --git a/src/user/views/user/CampaignView.tsx b/src/user/views/user/CampaignView.tsx
index 7054a1f9..dedf38d2 100644
--- a/src/user/views/user/CampaignView.tsx
+++ b/src/user/views/user/CampaignView.tsx
@@ -100,35 +100,49 @@ function CampaignHeader(props: { selectedCampaigns: string[] }) {
skip: !oneCampaignSelected || !firstCampaign,
});
- let tooltip: string | null = "Please select one campaign to clone or edit";
let isValidCampaign = false;
if (!loading && data?.campaign) {
isValidCampaign =
data.campaign.source === CampaignSource.SelfServe &&
editableCampaigns.includes(data.campaign.format) &&
data.campaign.state !== "completed";
- tooltip = isValidCampaign ? null : "Cannot edit this campaign";
}
return (
Campaigns
-
-
-
- }
- clickable
- />
-
-
+
+
+
+
+
+
+
+
+ }
+ clickable
+ />
+
+
+
);
}