From 26b2eed60dd80aa0c741d8309f1375b809c1f3f1 Mon Sep 17 00:00:00 2001 From: giancarlo Date: Sun, 2 Jun 2024 12:22:52 +0700 Subject: [PATCH] Update pricing table to exclude flat line items The pricing table component now filters out flat line items as they do not require further explanation. Consequently, changes have been made to the billing sample configuration file, turning a previously metered item into a flat one for clearer demonstration of usage. --- apps/web/config/billing.sample.config.ts | 9 +-------- .../billing/gateway/src/components/pricing-table.tsx | 8 +++++--- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/apps/web/config/billing.sample.config.ts b/apps/web/config/billing.sample.config.ts index b33b62ec3..23bac72b0 100644 --- a/apps/web/config/billing.sample.config.ts +++ b/apps/web/config/billing.sample.config.ts @@ -33,14 +33,7 @@ export default createBillingSchema({ id: 'price_1NNwYHI1i3VnbZTqI2UzaHIe', name: 'Addon 2', cost: 9.99, - type: 'metered' as const, - unit: 'GB', - tiers: [ - { - cost: 0.5, - upTo: 'unlimited', - }, - ], + type: 'flat' as const, }, ], }, diff --git a/packages/billing/gateway/src/components/pricing-table.tsx b/packages/billing/gateway/src/components/pricing-table.tsx index b15fb665f..e4ab8b96b 100644 --- a/packages/billing/gateway/src/components/pricing-table.tsx +++ b/packages/billing/gateway/src/components/pricing-table.tsx @@ -150,9 +150,11 @@ function PricingItem( const lineItem = props.primaryLineItem; - // we want to exclude the primary plan from the list of line items - // since we are displaying the primary line item separately as the main price - const lineItemsToDisplay = props.plan.lineItems; + // we exclude flat line items from the details since + // it doesn't need further explanation + const lineItemsToDisplay = props.plan.lineItems.filter((item) => { + return item.type !== 'flat'; + }); return (