Skip to content

Commit

Permalink
Refactor formatPricingPlan
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan committed Aug 1, 2019
1 parent 272bf3d commit ad6916d
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions app/apps/client/admin/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down

0 comments on commit ad6916d

Please sign in to comment.