From 56b9117ba541f948481afe2b563b7e7c029246a2 Mon Sep 17 00:00:00 2001 From: Tasso Evangelista Date: Tue, 30 Jul 2019 18:21:16 -0300 Subject: [PATCH 1/3] Fix app pricing plan description --- app/apps/client/admin/helpers.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/apps/client/admin/helpers.js b/app/apps/client/admin/helpers.js index c94b74a44551..fb9cdd9ded34 100644 --- a/app/apps/client/admin/helpers.js +++ b/app/apps/client/admin/helpers.js @@ -357,15 +357,19 @@ export const appStatusSpanProps = ({ export const formatPrice = (price) => `\$${ Number.parseFloat(price).toFixed(2) }`; export const formatPricingPlan = (pricingPlan) => { - const perUser = pricingPlan.isPerSeat && pricingPlan.tiers && pricingPlan.tiers.length; + const { strategy, price } = pricingPlan; + + const tier = Array.isArray(pricingPlan.tiers) + ? pricingPlan.tiers.find((tier) => tier.price === price) + : null; const pricingPlanTranslationString = [ 'Apps_Marketplace_pricingPlan', - pricingPlan.strategy, - perUser && 'perUser', + strategy, + (tier && tier.perUnit) && 'perUser', ].filter(Boolean).join('_'); return t(pricingPlanTranslationString, { - price: formatPrice(pricingPlan.price), + price: formatPrice(price), }); }; From c26c434c4d4e9ac7d48e0285e4bd3a59d48be041 Mon Sep 17 00:00:00 2001 From: Douglas Gubert Date: Wed, 31 Jul 2019 12:20:30 -0300 Subject: [PATCH 2/3] Update app/apps/client/admin/helpers.js Co-Authored-By: Diego Sampaio --- app/apps/client/admin/helpers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/apps/client/admin/helpers.js b/app/apps/client/admin/helpers.js index fb9cdd9ded34..6fd4555e8a0b 100644 --- a/app/apps/client/admin/helpers.js +++ b/app/apps/client/admin/helpers.js @@ -366,7 +366,7 @@ export const formatPricingPlan = (pricingPlan) => { const pricingPlanTranslationString = [ 'Apps_Marketplace_pricingPlan', strategy, - (tier && tier.perUnit) && 'perUser', + tier && tier.perUnit && 'perUser', ].filter(Boolean).join('_'); return t(pricingPlanTranslationString, { From ad6916d31a56bd87bf04979ac5d3adc34fe583de Mon Sep 17 00:00:00 2001 From: Tasso Evangelista Date: Thu, 1 Aug 2019 11:51:35 -0300 Subject: [PATCH 3/3] Refactor formatPricingPlan --- app/apps/client/admin/helpers.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app/apps/client/admin/helpers.js b/app/apps/client/admin/helpers.js index f24c98f95c45..839974e465ed 100644 --- a/app/apps/client/admin/helpers.js +++ b/app/apps/client/admin/helpers.js @@ -364,17 +364,13 @@ export const appStatusSpanProps = ({ export const formatPrice = (price) => `\$${ Number.parseFloat(price).toFixed(2) }`; -export const formatPricingPlan = (pricingPlan) => { - const { strategy, price } = pricingPlan; - - const tier = Array.isArray(pricingPlan.tiers) - ? pricingPlan.tiers.find((tier) => tier.price === price) - : null; +export const formatPricingPlan = ({ strategy, price, tiers }) => { + const { perUnit = false } = (Array.isArray(tiers) && tiers.find((tier) => tier.price === price)) || {}; const pricingPlanTranslationString = [ 'Apps_Marketplace_pricingPlan', strategy, - tier && tier.perUnit && 'perUser', + perUnit && 'perUser', ].filter(Boolean).join('_'); return t(pricingPlanTranslationString, {