Context
Currently, pricing calculation logic is implemented directly in the PricingCards component. This logic should be shared between the web and mkt packages to ensure consistency.
Current Implementation
const basePrice = 49;
const discount = isYearly ? 0.8 : 1;
const pricePerExtraContributor = 7 * discount;
const discountedPrice = Math.floor(basePrice * discount);
const extraContributors = Math.max(contributors - 5, 0);
const totalPrice = discountedPrice + extraContributors * pricePerExtraContributor;
Proposed Solution
Extract the pricing calculation into a shared utility that can be consumed by both packages:
interface PricingOptions {
contributors: number;
isYearly: boolean;
}
export function calculatePrice({ contributors, isYearly }: PricingOptions) {
const basePrice = 49;
const discount = isYearly ? 0.8 : 1;
const pricePerExtraContributor = 7 * discount;
const discountedPrice = Math.floor(basePrice * discount);
const extraContributors = Math.max(contributors - 5, 0);
return discountedPrice + extraContributors * pricePerExtraContributor;
}
References
Context
Currently, pricing calculation logic is implemented directly in the
PricingCardscomponent. This logic should be shared between the web and mkt packages to ensure consistency.Current Implementation
Proposed Solution
Extract the pricing calculation into a shared utility that can be consumed by both packages:
References