From e736633d4ecc89bbca043256f4ff231299f9f39a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CLAKSHMIRPILLAI=E2=80=9D?= <“luxmi.r.pillai@gmail.com”> Date: Wed, 22 Jan 2025 11:38:14 +0000 Subject: [PATCH] Remove RegionTargetingType and add changes for Banners --- app/models/BannerTests.scala | 1 + app/models/EpicTest.scala | 1 - app/models/RegionTargetingType.scala | 6 ---- .../MultiSelectCountryEditor.tsx | 2 +- .../bannerTests/bannerTestEditor.tsx | 6 ++++ .../bannerTests/utils/defaults.ts | 2 ++ .../epicTests/testEditor.tsx | 6 ++-- .../epicTests/utils/defaults.ts | 8 +---- .../testEditorTargetAudienceSelector.tsx | 34 +++++++++++-------- public/src/models/banner.ts | 1 + public/src/models/epic.ts | 8 +---- public/src/utils/models.tsx | 2 +- 12 files changed, 37 insertions(+), 40 deletions(-) delete mode 100644 app/models/RegionTargetingType.scala diff --git a/app/models/BannerTests.scala b/app/models/BannerTests.scala index 84902522..021cc95d 100644 --- a/app/models/BannerTests.scala +++ b/app/models/BannerTests.scala @@ -38,6 +38,7 @@ case class BannerTest( nickname: Option[String], userCohort: UserCohort, locations: List[Region] = Nil, + targetedCountries: List[String] = Nil, contextTargeting: PageContextTargeting = PageContextTargeting(Nil,Nil,Nil,Nil), variants: List[BannerVariant], articlesViewedSettings: Option[ArticlesViewedSettings] = None, diff --git a/app/models/EpicTest.scala b/app/models/EpicTest.scala index 234af8aa..fafe52ad 100644 --- a/app/models/EpicTest.scala +++ b/app/models/EpicTest.scala @@ -47,7 +47,6 @@ case class EpicTest( nickname: Option[String], locations: List[Region] = Nil, targetedCountries: List[String] = Nil, - regionTargetingType : Option[RegionTargetingType] = None, tagIds: List[String] = Nil, sections: List[String] = Nil, excludedTagIds: List[String] = Nil, diff --git a/app/models/RegionTargetingType.scala b/app/models/RegionTargetingType.scala deleted file mode 100644 index 4c4270ff..00000000 --- a/app/models/RegionTargetingType.scala +++ /dev/null @@ -1,6 +0,0 @@ -package models - -case class RegionTargetingType( - locations: List[Region] = Nil, - targetedCountries: List[String] = Nil, - ) diff --git a/public/src/components/channelManagement/MultiSelectCountryEditor.tsx b/public/src/components/channelManagement/MultiSelectCountryEditor.tsx index bddd1ad8..6ee446e7 100644 --- a/public/src/components/channelManagement/MultiSelectCountryEditor.tsx +++ b/public/src/components/channelManagement/MultiSelectCountryEditor.tsx @@ -4,7 +4,7 @@ import TextField from '@mui/material/TextField'; import { makeStyles } from '@mui/styles'; import { grey } from '@mui/material/colors'; import { Theme } from '@mui/material/styles'; -import { countryNames, Region } from '../../utils/models'; +import { countryNames } from '../../utils/models'; const useStyles = makeStyles(({ spacing }: Theme) => ({ container: { diff --git a/public/src/components/channelManagement/bannerTests/bannerTestEditor.tsx b/public/src/components/channelManagement/bannerTests/bannerTestEditor.tsx index 82b49d2c..8e266fce 100644 --- a/public/src/components/channelManagement/bannerTests/bannerTestEditor.tsx +++ b/public/src/components/channelManagement/bannerTests/bannerTestEditor.tsx @@ -135,6 +135,10 @@ const BannerTestEditor: React.FC> = ({ updateTest({ ...test, locations: updatedRegions }); }; + const onCountriesChange = (updatedCountries: string[]): void => { + updateTest({ ...test, targetedCountries: updatedCountries }); + }; + const onCohortChange = (updatedCohort: UserCohort): void => { updateTest({ ...test, userCohort: updatedCohort }); }; @@ -297,6 +301,8 @@ const BannerTestEditor: React.FC> = ({ { - updateTest({ ...test, locations: updatedRegions }); // TODO change to targetingType + updateTest({ ...test, locations: updatedRegions }); }; const onCountriesChange = (updatedCountries: string[]): void => { updateTest({ ...test, targetedCountries: updatedCountries }); @@ -353,8 +353,8 @@ export const getEpicTestEditor = ( ({ color: palette.grey[900], fontWeight: 500, }, + container1: { + display: 'inline', + gap: spacing(12), + flexWrap: 'wrap', + }, })); interface TestEditorTargetAudienceSelectorProps { @@ -73,21 +78,22 @@ const TestEditorTargetAudienceSelector: React.FC - Region - - - +
+ Region + + {})} + /> +
{showSupporterStatusSelector && ( <> Supporter Status diff --git a/public/src/models/banner.ts b/public/src/models/banner.ts index f387992b..0e307f90 100644 --- a/public/src/models/banner.ts +++ b/public/src/models/banner.ts @@ -45,6 +45,7 @@ export interface BannerTest extends Test { status: Status; userCohort: UserCohort; locations: Region[]; + targetedCountries?: string[]; variants: BannerVariant[]; articlesViewedSettings?: ArticlesViewedSettings; controlProportionSettings?: ControlProportionSettings; diff --git a/public/src/models/epic.ts b/public/src/models/epic.ts index 4380c552..6713f83b 100644 --- a/public/src/models/epic.ts +++ b/public/src/models/epic.ts @@ -44,18 +44,12 @@ export interface MaxEpicViews { minDaysBetweenViews: number; } -export interface RegionTargetingType { - locations?: Region[]; - targetedCountries?: string[]; -} - export interface EpicTest extends Test { name: string; nickname?: string; status: Status; locations: Region[]; - targetedCountries: string[]; - targetingType?: RegionTargetingType; + targetedCountries?: string[]; tagIds: string[]; sections: string[]; excludedTagIds: string[]; diff --git a/public/src/utils/models.tsx b/public/src/utils/models.tsx index c28d75ba..6e8170d3 100644 --- a/public/src/utils/models.tsx +++ b/public/src/utils/models.tsx @@ -287,7 +287,7 @@ export const countries: CommonStringObject = { ZW: 'Zimbabwe', }; -export const countryNames = Object.entries(countries).map(_ =>[_[0], _[1]]); +export const countryNames = Object.entries(countries).map(_ => [_[0], _[1]]); export type Country = keyof typeof countries; export interface AmountValuesObject {