-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
good first issueGood for newcomersGood for newcomers
Description
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
- PR: /feat: mkt pricing calculator + shadcn #41
- Comment: /feat: mkt pricing calculator + shadcn #41#discussion_r1906448159
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomers