Skip to content

Commit

Permalink
Update marketing boosts display (#7174)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementPasteau authored Nov 18, 2024
1 parent 9eada90 commit c5fc7e0
Show file tree
Hide file tree
Showing 5 changed files with 236 additions and 98 deletions.
11 changes: 8 additions & 3 deletions newIDE/app/src/MarketingPlans/MarketingPlanFeatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,12 @@ const MarketingPlanFeatures = ({
canExtend,
descriptionByLocale,
bulletPointsByLocale,
ownedBulletPointsByLocale,
} = marketingPlan;

const activeGameFeaturings: ?(GameFeaturing[]) = React.useMemo(
const activeGameFeaturings: GameFeaturing[] = React.useMemo(
() => {
if (!gameFeaturings) return null;
if (!gameFeaturings) return [];

return gameFeaturings.filter(
gameFeaturing => gameFeaturing.expiresAt > Date.now() / 1000
Expand All @@ -88,6 +89,10 @@ const MarketingPlanFeatures = ({
}
const hasErrors = requirementsErrors.length > 0;

const bulletPointsToDisplay = isPlanActive
? ownedBulletPointsByLocale
: bulletPointsByLocale;

return (
<I18n>
{({ i18n }) => (
Expand Down Expand Up @@ -142,7 +147,7 @@ const MarketingPlanFeatures = ({
</Line>
</Column>
))
: bulletPointsByLocale.map((bulletPointByLocale, index) => (
: bulletPointsToDisplay.map((bulletPointByLocale, index) => (
<Column key={index} expand noMargin>
<Line noMargin alignItems="center">
<CheckCircle
Expand Down
15 changes: 8 additions & 7 deletions newIDE/app/src/MarketingPlans/MarketingPlanUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ export const getIconForMarketingPlan = (marketingPlan: MarketingPlan) => {

const getActiveFeaturingsOfMarketingPlan = (
marketingPlan: MarketingPlan,
activeGameFeaturings: ?(GameFeaturing[])
activeGameFeaturings: GameFeaturing[]
) => {
if (!activeGameFeaturings) return [];

return activeGameFeaturings.filter(activeGameFeaturing =>
marketingPlan.includedFeaturings.includes(activeGameFeaturing.featuring)
);
Expand Down Expand Up @@ -104,18 +102,21 @@ export const getActiveMessage = ({
marketingPlan: MarketingPlan,
i18n: I18nType,
hasErrors: boolean,
activeGameFeaturings: ?(GameFeaturing[]),
activeGameFeaturings: GameFeaturing[],
|}) => {
if (hasErrors) {
return <Trans>Fix those issues to get the campaign up!</Trans>;
}

const activeFeaturingsForPlan = getActiveFeaturingsOfMarketingPlan(
marketingPlan
marketingPlan,
activeGameFeaturings
);

if (activeFeaturingsForPlan.length === 0) {
// Should not happen.
if (
activeFeaturingsForPlan.length === 0 || // Still loading or no active featurings
!marketingPlan.showExpirationDate
) {
return null;
}

Expand Down
5 changes: 3 additions & 2 deletions newIDE/app/src/Utils/GDevelopServices/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ export type FeaturingType =
| 'games-platform-home'
| 'games-platform-game-page'
| 'games-platform-listing'
| 'socials-newsletter'
| 'gdevelop-banner';
| 'games-platform-guaranteed-sessions';

export type GameFeaturing = {|
gameId: string,
Expand Down Expand Up @@ -164,7 +163,9 @@ export type MarketingPlan = {|
nameByLocale: MessageByLocale,
descriptionByLocale: MessageByLocale,
bulletPointsByLocale: Array<MessageByLocale>,
ownedBulletPointsByLocale: Array<MessageByLocale>,
additionalSuccessMessageByLocale: MessageByLocale,
showExpirationDate: boolean,
|};

export type GameLeaderboardEntry = {
Expand Down
9 changes: 2 additions & 7 deletions newIDE/app/src/fixtures/GDevelopServicesTestData/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2362,10 +2362,10 @@ const prices = {
priceInCredits: 500,
},
'featuring-pro': {
priceInCredits: 900,
priceInCredits: 1000,
},
'featuring-premium': {
priceInCredits: 4000,
priceInCredits: 3000,
},
};

Expand Down Expand Up @@ -2463,11 +2463,6 @@ export const limitsForSilverUser: Limits = {
max: 1000,
limitReached: false,
},
'ask-question': {
current: 1,
max: 3,
limitReached: false,
},
'ask-question': {
current: 1,
max: 10,
Expand Down
Loading

0 comments on commit c5fc7e0

Please sign in to comment.