File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
apps/docs/app/(home)/pricing/_pricing Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,16 @@ function calculateTotalCost(
2424 return basePrice + overageCost ;
2525}
2626
27+ function findHighestTierPlan ( plans : NormalizedPlan [ ] ) : NormalizedPlan | null {
28+ const paidPlansWithOverage = plans . filter ( ( p ) => p . eventTiers !== null ) ;
29+ if ( paidPlansWithOverage . length === 0 ) {
30+ return null ;
31+ }
32+ return paidPlansWithOverage . reduce ( ( max , plan ) =>
33+ plan . includedEventsMonthly > max . includedEventsMonthly ? plan : max
34+ ) ;
35+ }
36+
2737export function selectBestPlan (
2838 monthlyEvents : number ,
2939 plans : NormalizedPlan [ ]
@@ -32,6 +42,11 @@ export function selectBestPlan(
3242 return null ;
3343 }
3444
45+ const highestTier = findHighestTierPlan ( plans ) ;
46+
47+ if ( highestTier && monthlyEvents > highestTier . includedEventsMonthly ) {
48+ return highestTier ;
49+ }
3550 let bestPlan : NormalizedPlan | null = null ;
3651 let bestCost = Number . POSITIVE_INFINITY ;
3752
You can’t perform that action at this time.
0 commit comments