From efc2e0e3f8c29f95a81942374c7c1200814c2a8b Mon Sep 17 00:00:00 2001 From: Egor Date: Sun, 18 Jan 2026 06:11:52 +0300 Subject: [PATCH] Update PromoDiscountBadge.tsx --- src/components/PromoDiscountBadge.tsx | 99 ++++++++++++++------------- 1 file changed, 50 insertions(+), 49 deletions(-) diff --git a/src/components/PromoDiscountBadge.tsx b/src/components/PromoDiscountBadge.tsx index a0d005a..8f4f845 100644 --- a/src/components/PromoDiscountBadge.tsx +++ b/src/components/PromoDiscountBadge.tsx @@ -16,7 +16,7 @@ const ClockIcon = () => ( ) -const formatTimeLeft = (expiresAt: string): string => { +const formatTimeLeft = (expiresAt: string, t: (key: string) => string): string => { const now = new Date() const expires = new Date(expiresAt) const diffMs = expires.getTime() - now.getTime() @@ -28,12 +28,12 @@ const formatTimeLeft = (expiresAt: string): string => { if (hours > 24) { const days = Math.floor(hours / 24) - return `${days}д` + return `${days}${t('promo.time.days')}` } if (hours > 0) { - return `${hours}ч ${minutes}м` + return `${hours}${t('promo.time.hours')} ${minutes}${t('promo.time.minutes')}` } - return `${minutes}м` + return `${minutes}${t('promo.time.minutes')}` } export default function PromoDiscountBadge() { @@ -65,7 +65,7 @@ export default function PromoDiscountBadge() { return null } - const timeLeft = activeDiscount.expires_at ? formatTimeLeft(activeDiscount.expires_at) : null + const timeLeft = activeDiscount.expires_at ? formatTimeLeft(activeDiscount.expires_at, t) : null const handleClick = () => { setIsOpen(!isOpen) @@ -96,56 +96,57 @@ export default function PromoDiscountBadge() { - {/* Dropdown */} + {/* Dropdown - mobile: fixed centered, desktop: absolute right */} {isOpen && ( -
- {/* Header */} -
-
-
- -
-
-
- {t('promo.discountActive', 'Discount active!')} + <> + {/* Mobile backdrop */} +
setIsOpen(false)} + /> + +
+ {/* Header */} +
+
+
+
-
- -{activeDiscount.discount_percent}% +
+
+ {t('promo.discountActive')} +
+
+ -{activeDiscount.discount_percent}% +
+ + {/* Content */} +
+

+ {t('promo.discountDescription')} +

+ + {/* Time remaining */} + {timeLeft && ( +
+ + {t('promo.expiresIn')}: {timeLeft} +
+ )} + + {/* CTA Button */} + +
- - {/* Content */} -
-

- {t('promo.discountDescription', 'Your personal discount is applied to subscription purchases')} -

- - {/* Time remaining */} - {timeLeft && ( -
- - {t('promo.expiresIn', 'Expires in')}: {timeLeft} -
- )} - - {/* Source info */} - {activeDiscount.source && ( -
- {t('promo.source', 'Source')}: {activeDiscount.source} -
- )} - - {/* CTA Button */} - -
-
+ )}
)