diff --git a/src/api/subscription.ts b/src/api/subscription.ts index 868d517..99fe63d 100644 --- a/src/api/subscription.ts +++ b/src/api/subscription.ts @@ -91,6 +91,11 @@ export const subscriptionApi = { can_add?: number; days_left?: number; base_device_price_kopeks?: number; + // Discount fields (from promo group) + original_price_per_device_kopeks?: number; + base_total_price_kopeks?: number; + discount_percent?: number; + discount_kopeks?: number; }> => { const response = await apiClient.get('/cabinet/subscription/devices/price', { params: { devices }, @@ -355,6 +360,10 @@ export const subscriptionApi = { missing_amount_kopeks: number; missing_amount_label: string; is_upgrade: boolean; + // Discount fields (from promo group) + base_upgrade_cost_kopeks?: number; + discount_percent?: number; + discount_kopeks?: number; }> => { const response = await apiClient.post('/cabinet/subscription/tariff/switch/preview', { tariff_id: tariffId, diff --git a/src/pages/Subscription.tsx b/src/pages/Subscription.tsx index 1f8e048..9be84c7 100644 --- a/src/pages/Subscription.tsx +++ b/src/pages/Subscription.tsx @@ -1215,13 +1215,47 @@ export default function Subscription() { {devicePriceData?.available && devicePriceData.price_per_device_label && (
- {devicePriceData.price_per_device_label}/ - {t('subscription.perDevice').replace('/ ', '')} ( + {/* Show original price with strikethrough if discount */} + {devicePriceData.discount_percent && + devicePriceData.discount_percent > 0 ? ( + + + {formatPrice(devicePriceData.original_price_per_device_kopeks || 0)} + + {devicePriceData.price_per_device_label} + + ) : ( + devicePriceData.price_per_device_label + )} + /{t('subscription.perDevice').replace('/ ', '')} ( {t('subscription.days', { count: devicePriceData.days_left })})
-
- {devicePriceData.total_price_label} -
+ {/* Discount badge */} + {devicePriceData.discount_percent && devicePriceData.discount_percent > 0 && ( +
+ + -{devicePriceData.discount_percent}% + +
+ )} + {/* Total price - show as free if 100% discount or 0 */} + {devicePriceData.total_price_kopeks === 0 ? ( +
+ {t('subscription.switchTariff.free')} +
+ ) : ( +
+ {/* Show original total with strikethrough if discount */} + {devicePriceData.discount_percent && + devicePriceData.discount_percent > 0 && + devicePriceData.base_total_price_kopeks && ( + + {formatPrice(devicePriceData.base_total_price_kopeks)} + + )} + {devicePriceData.total_price_label} +
+ )}
)} @@ -1514,8 +1548,28 @@ export default function Subscription() { ? '♾️ ' + t('subscription.additionalOptions.unlimited') : `${pkg.gb} ${t('common.units.gb')}`} + {/* Discount badge */} + {pkg.discount_percent && pkg.discount_percent > 0 && ( +
+ + -{pkg.discount_percent}% + +
+ )} + {/* Price with original strikethrough if discount */}
- {formatPrice(pkg.price_kopeks)} + {pkg.discount_percent && + pkg.discount_percent > 0 && + pkg.base_price_kopeks ? ( + <> + + {formatPrice(pkg.base_price_kopeks)} + + {formatPrice(pkg.price_kopeks)} + + ) : ( + formatPrice(pkg.price_kopeks) + )}
))} @@ -2102,14 +2156,35 @@ export default function Subscription() { )}
- - {t('subscription.switchTariff.upgradeCost')} - - - {switchPreview.upgrade_cost_kopeks > 0 - ? switchPreview.upgrade_cost_label - : t('subscription.switchTariff.free')} - +
+ + {t('subscription.switchTariff.upgradeCost')} + + {/* Discount badge */} + {switchPreview.discount_percent && switchPreview.discount_percent > 0 && ( + + -{switchPreview.discount_percent}% + + )} +
+
+ {/* Show original price with strikethrough if discount */} + {switchPreview.discount_percent && + switchPreview.discount_percent > 0 && + switchPreview.base_upgrade_cost_kopeks && + switchPreview.base_upgrade_cost_kopeks > 0 && ( + + {formatPrice(switchPreview.base_upgrade_cost_kopeks)} + + )} + + {switchPreview.upgrade_cost_kopeks > 0 + ? switchPreview.upgrade_cost_label + : t('subscription.switchTariff.free')} + +
{!switchPreview.has_enough_balance && diff --git a/src/types/index.ts b/src/types/index.ts index 0d9e1ff..0019b42 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -122,6 +122,10 @@ export interface TariffSwitchPreview { missing_amount_kopeks: number; missing_amount_label: string; is_upgrade: boolean; + // Discount fields (from promo group) + base_upgrade_cost_kopeks?: number; + discount_percent?: number; + discount_kopeks?: number; } export interface RenewalOption { @@ -137,6 +141,10 @@ export interface TrafficPackage { price_kopeks: number; price_rubles: number; is_unlimited: boolean; + // Discount fields (from promo group) + base_price_kopeks?: number; + discount_percent?: number; + discount_kopeks?: number; } export interface TrialInfo {