From 599bdc1338af1ab9975307d5555ccfa5846a3bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczyk?= Date: Tue, 24 May 2022 18:58:12 +0200 Subject: [PATCH] Dashboard V2: Fix extraneous tiers on /payments screen --- .../src/contexts/plans/PlansProvider.js | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/dashboard-v2/src/contexts/plans/PlansProvider.js b/packages/dashboard-v2/src/contexts/plans/PlansProvider.js index 7c6579ad..6edcbc0b 100644 --- a/packages/dashboard-v2/src/contexts/plans/PlansProvider.js +++ b/packages/dashboard-v2/src/contexts/plans/PlansProvider.js @@ -19,14 +19,20 @@ const aggregatePlansAndLimits = (plans, limits, { includeFreePlan }) => { // Decorate each plan with its corresponding limits data, if available. if (limits?.length) { - return limits.map((limitsDescriptor, index) => { - const asssociatedPlan = sortedPlans.find((plan) => plan.tier === index) || {}; + return limits + .map((limitsDescriptor, index) => { + const asssociatedPlan = sortedPlans.find((plan) => plan.tier === index); - return { - ...asssociatedPlan, - limits: limitsDescriptor || null, - }; - }); + if (asssociatedPlan) { + return { + ...asssociatedPlan, + limits: limitsDescriptor || null, + }; + } + + return null; + }) + .filter(Boolean); } // If we don't have the limits data yet, set just return the plans.