Fixing PLans page
This commit is contained in:
@@ -5,6 +5,7 @@ export interface PricingPlan {
|
||||
name: string;
|
||||
price: string | number; // Current displayed price (will be calculated based on period)
|
||||
monthlyPrice?: string | number; // Base monthly price (used for annual discount calculation)
|
||||
annualDiscountPercent?: number; // Annual discount percentage from backend (default 15%)
|
||||
originalPrice?: string | number;
|
||||
period?: string; // "/month", "/year", "/Lifetime"
|
||||
description?: string;
|
||||
@@ -63,7 +64,7 @@ export default function PricingTable({
|
||||
return price;
|
||||
};
|
||||
|
||||
// Calculate price based on billing period with 20% annual discount
|
||||
// Calculate price based on billing period with discount from backend
|
||||
const getDisplayPrice = (plan: PricingPlan): { price: number; originalPrice?: number } => {
|
||||
const monthlyPrice = typeof plan.monthlyPrice === 'number'
|
||||
? plan.monthlyPrice
|
||||
@@ -72,8 +73,12 @@ export default function PricingTable({
|
||||
: parseFloat(String(plan.price || 0));
|
||||
|
||||
if (billingPeriod === 'annually' && showToggle) {
|
||||
// Annual price: monthly * 12 * 0.8 (20% discount)
|
||||
const annualPrice = monthlyPrice * 12 * 0.8;
|
||||
// Get discount percentage from plan (default 15%)
|
||||
const discountPercent = plan.annualDiscountPercent || 15;
|
||||
const discountMultiplier = (100 - discountPercent) / 100;
|
||||
|
||||
// Annual price: monthly * 12 * discount multiplier
|
||||
const annualPrice = monthlyPrice * 12 * discountMultiplier;
|
||||
const originalAnnualPrice = monthlyPrice * 12;
|
||||
return { price: annualPrice, originalPrice: originalAnnualPrice };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user