Add support for custom pricing plans in PricingItem component (#138)

- Introduced `custom` flag to handle custom pricing plan display
- Conditionally render custom plan label when `isCustom` is true
- Updated TypeScript type for plan to include optional `custom` property
This commit is contained in:
Giancarlo Buomprisco
2025-02-04 06:27:27 +07:00
committed by GitHub
parent 77131d886c
commit 3553422e42

View File

@@ -132,6 +132,7 @@ function PricingItem(
name?: string; name?: string;
href?: string; href?: string;
label?: string; label?: string;
custom?: boolean;
}; };
CheckoutButton?: React.ComponentType<{ CheckoutButton?: React.ComponentType<{
@@ -153,6 +154,7 @@ function PricingItem(
) { ) {
const highlighted = props.product.highlighted ?? false; const highlighted = props.product.highlighted ?? false;
const lineItem = props.primaryLineItem!; const lineItem = props.primaryLineItem!;
const isCustom = props.plan.custom ?? false;
// we exclude flat line items from the details since // we exclude flat line items from the details since
// it doesn't need further explanation // it doesn't need further explanation
@@ -217,12 +219,14 @@ function PricingItem(
<div className={'flex flex-col space-y-2'}> <div className={'flex flex-col space-y-2'}>
<Price isMonthlyPrice={props.alwaysDisplayMonthlyPrice}> <Price isMonthlyPrice={props.alwaysDisplayMonthlyPrice}>
<PlanCostDisplay <If condition={!isCustom} fallback={props.plan.label}>
primaryLineItem={lineItem} <PlanCostDisplay
currencyCode={props.product.currency} primaryLineItem={lineItem}
interval={interval} currencyCode={props.product.currency}
alwaysDisplayMonthlyPrice={props.alwaysDisplayMonthlyPrice} interval={interval}
/> alwaysDisplayMonthlyPrice={props.alwaysDisplayMonthlyPrice}
/>
</If>
</Price> </Price>
<If condition={props.plan.name}> <If condition={props.plan.name}>