From 07775067632194f5203d2c1fb2bcd300679e4f87 Mon Sep 17 00:00:00 2001
From: Ian Krieger <48930920+IanKrieger@users.noreply.github.com>
Date: Fri, 15 Sep 2023 09:26:34 -0400
Subject: [PATCH 1/2] fix: clone campaign created in self-serve, remove deleted
ads in edit (#887)
* fix: clone campaigns only created in self-serve, remove deleted ads in edit
* test: change default
---
src/components/Campaigns/CloneCampaign.tsx | 9 ++--
src/user/library/index.test.ts | 2 +-
src/user/library/index.ts | 7 ++-
src/user/views/user/CampaignView.tsx | 50 ++++++++++++++--------
4 files changed, 43 insertions(+), 25 deletions(-)
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
+ />
+
+
+
);
}
From 09302cfd4e6855d3977e62f342abac3c3863c49f Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Fri, 15 Sep 2023 09:29:12 -0400
Subject: [PATCH 2/2] chore(deps): update all non-major dependencies (#885)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
---
package-lock.json | 32 ++++++++++++++++----------------
package.json | 4 ++--
2 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index 327ee376..83f01130 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -59,7 +59,7 @@
"@typescript-eslint/parser": "6.6.0",
"@vitejs/plugin-basic-ssl": "1.0.1",
"@vitejs/plugin-react": "4.0.4",
- "eslint": "8.48.0",
+ "eslint": "8.49.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-react": "7.33.2",
"husky": "8.0.3",
@@ -67,7 +67,7 @@
"typescript": "5.2.2",
"vite": "4.4.9",
"vite-plugin-checker": "0.6.2",
- "vite-tsconfig-paths": "4.2.0",
+ "vite-tsconfig-paths": "4.2.1",
"vitest": "0.34.4"
}
},
@@ -1897,9 +1897,9 @@
}
},
"node_modules/@eslint/js": {
- "version": "8.48.0",
- "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.48.0.tgz",
- "integrity": "sha512-ZSjtmelB7IJfWD2Fvb7+Z+ChTIKWq6kjda95fLcQKNS5aheVHn4IkfgRQE3sIIzTcSLwLcLZUD9UBt+V7+h+Pw==",
+ "version": "8.49.0",
+ "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.49.0.tgz",
+ "integrity": "sha512-1S8uAY/MTJqVx0SC4epBq+N2yhuwtNwLbJYNZyhL2pO1ZVKn5HFXav5T41Ryzy9K9V7ZId2JB2oy/W4aCd9/2w==",
"dev": true,
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@@ -2746,9 +2746,9 @@
}
},
"node_modules/@humanwhocodes/config-array": {
- "version": "0.11.10",
- "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz",
- "integrity": "sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==",
+ "version": "0.11.11",
+ "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.11.tgz",
+ "integrity": "sha512-N2brEuAadi0CcdeMXUkhbZB84eskAc8MEX1By6qEchoVywSgXPIjou4rYsl0V3Hj0ZnuGycGCjdNgockbzeWNA==",
"dev": true,
"dependencies": {
"@humanwhocodes/object-schema": "^1.2.1",
@@ -5657,16 +5657,16 @@
}
},
"node_modules/eslint": {
- "version": "8.48.0",
- "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.48.0.tgz",
- "integrity": "sha512-sb6DLeIuRXxeM1YljSe1KEx9/YYeZFQWcV8Rq9HfigmdDEugjLEVEa1ozDjL6YDjBpQHPJxJzze+alxi4T3OLg==",
+ "version": "8.49.0",
+ "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.49.0.tgz",
+ "integrity": "sha512-jw03ENfm6VJI0jA9U+8H5zfl5b+FvuU3YYvZRdZHOlU2ggJkxrlkJH4HcDrZpj6YwD8kuYqvQM8LyesoazrSOQ==",
"dev": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.2.0",
"@eslint-community/regexpp": "^4.6.1",
"@eslint/eslintrc": "^2.1.2",
- "@eslint/js": "8.48.0",
- "@humanwhocodes/config-array": "^0.11.10",
+ "@eslint/js": "8.49.0",
+ "@humanwhocodes/config-array": "^0.11.11",
"@humanwhocodes/module-importer": "^1.0.1",
"@nodelib/fs.walk": "^1.2.8",
"ajv": "^6.12.4",
@@ -10546,9 +10546,9 @@
}
},
"node_modules/vite-tsconfig-paths": {
- "version": "4.2.0",
- "resolved": "https://registry.npmjs.org/vite-tsconfig-paths/-/vite-tsconfig-paths-4.2.0.tgz",
- "integrity": "sha512-jGpus0eUy5qbbMVGiTxCL1iB9ZGN6Bd37VGLJU39kTDD6ZfULTTb1bcc5IeTWqWJKiWV5YihCaibeASPiGi8kw==",
+ "version": "4.2.1",
+ "resolved": "https://registry.npmjs.org/vite-tsconfig-paths/-/vite-tsconfig-paths-4.2.1.tgz",
+ "integrity": "sha512-GNUI6ZgPqT3oervkvzU+qtys83+75N/OuDaQl7HmOqFTb0pjZsuARrRipsyJhJ3enqV8beI1xhGbToR4o78nSQ==",
"dev": true,
"dependencies": {
"debug": "^4.1.1",
diff --git a/package.json b/package.json
index 9d487bb0..b356e060 100644
--- a/package.json
+++ b/package.json
@@ -68,7 +68,7 @@
"@typescript-eslint/parser": "6.6.0",
"@vitejs/plugin-basic-ssl": "1.0.1",
"@vitejs/plugin-react": "4.0.4",
- "eslint": "8.48.0",
+ "eslint": "8.49.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-react": "7.33.2",
"husky": "8.0.3",
@@ -76,7 +76,7 @@
"typescript": "5.2.2",
"vite": "4.4.9",
"vite-plugin-checker": "0.6.2",
- "vite-tsconfig-paths": "4.2.0",
+ "vite-tsconfig-paths": "4.2.1",
"vitest": "0.34.4"
},
"overrides": {