diff --git a/miniapp/index.html b/miniapp/index.html index 1e892f2b..1c49a527 100644 --- a/miniapp/index.html +++ b/miniapp/index.html @@ -1171,6 +1171,10 @@ padding: 0 16px 0; } + .subscription-purchase-card.has-promo-details .card-content { + max-height: none; + } + .subscription-purchase-actions { display: flex; flex-direction: column; @@ -1303,6 +1307,14 @@ padding: 0 16px 0; } + .subscription-purchase-card.has-promo-details { + overflow: visible; + } + + .subscription-purchase-card.has-promo-details .card-content { + max-height: none; + } + .subscription-purchase-option-content { flex-direction: column; gap: 12px; @@ -16345,6 +16357,70 @@ || (preview?.missingAmountKopeks || 0) > 0; submitButton.disabled = disabled; } + + const cardElement = document.getElementById('subscriptionPurchaseCard'); + if (cardElement) { + let hasPromoDetails = false; + if (!loading && preview) { + const discountLines = ensureArray(preview.discountLines) + .map(line => { + if (typeof line === 'string') { + return line.trim(); + } + if (line && typeof line.label === 'string') { + return line.label.trim(); + } + return ''; + }) + .filter(Boolean); + + const rawPreview = preview.raw; + const promoRoots = []; + if (rawPreview && typeof rawPreview === 'object') { + promoRoots.push(rawPreview); + ['preview', 'data', 'summary', 'config', 'meta'].forEach(key => { + const candidate = rawPreview[key]; + if (candidate && typeof candidate === 'object') { + promoRoots.push(candidate); + } + }); + } + + const hasPromoFromRaw = promoRoots.some(entry => { + if (!entry || typeof entry !== 'object') { + return false; + } + + const groupActive = entry.promo_group + || entry.promoGroup + || entry.promo_group_active + || entry.promoGroupActive; + const offerActive = entry.promo_offer || entry.promoOffer; + const rawDiscounts = ensureArray( + entry.discount_lines + || entry.discountLines + || entry.promo + || entry.discounts, + ) + .map(item => { + if (typeof item === 'string') { + return item.trim(); + } + if (item && typeof item.label === 'string') { + return item.label.trim(); + } + return ''; + }) + .filter(Boolean); + + return Boolean(groupActive || offerActive || rawDiscounts.length); + }); + + hasPromoDetails = discountLines.length > 0 || hasPromoFromRaw; + } + + cardElement.classList.toggle('has-promo-details', hasPromoDetails); + } } function requestSubscriptionPurchasePreviewUpdate(options = {}) {