Fixing PLans page

This commit is contained in:
IGNY8 VPS (Salman)
2025-12-08 14:12:08 +00:00
parent da3b45d1c7
commit 144e955b92
24 changed files with 1992 additions and 1105 deletions

View File

@@ -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 };
}