From 49ff374529aa9558f30161ba234a33c2eb1fd2b8 Mon Sep 17 00:00:00 2001 From: Leon Date: Thu, 15 Jan 2026 15:13:03 +0100 Subject: [PATCH] feat: coin packs --- src/components/modal/CoinPackModal.js | 75 ++++++++++++++++++++++----- src/screens/Subscriptions.js | 72 ++++++++++++++++++++++--- 2 files changed, 127 insertions(+), 20 deletions(-) diff --git a/src/components/modal/CoinPackModal.js b/src/components/modal/CoinPackModal.js index 5118eaa..3840828 100644 --- a/src/components/modal/CoinPackModal.js +++ b/src/components/modal/CoinPackModal.js @@ -35,7 +35,7 @@ const formatCurrency = (amount, currency = 'eur') => { currency: upperCurrency, minimumFractionDigits: 2, }).format(normalized) - } catch (_error) {} + } catch (_error) { } } return `${normalized.toFixed(2)} ${upperCurrency}` @@ -45,6 +45,33 @@ const FALLBACK_BASE_PRICE_PER_COIN = 12 // ~0,12€ par jeton (valeur indicatif const FALLBACK_DISCOUNT_STEPS = [0, 12, 18, 26, 32] const STATIC_DISCOUNTS = [0, 30, 50] +const COIN_PACK_DETAILS = { + starter: { + label: 'Pack starter', + creditsDisplay: '50 Crédits', + disclaimer: '*Non-Eligible au concours Chanson/Vidéo', + }, + medium: { + label: 'Pack Medium', + creditsDisplay: '100 Crédits + 50 offerts', + disclaimer: '*Non-Eligible au concours Chanson/Vidéo', + }, + premium: { + label: 'Pack Premium', + creditsDisplay: '150 Crédits + 100 offerts', + disclaimer: '*Non-Eligible au concours Chanson/Vidéo', + }, +} + +const getCoinPackKey = (pack) => { + const name = (pack?.name || '').toLowerCase() + if (name.includes('starter')) return 'starter' + if (name.includes('medium')) return 'medium' + if (name.includes('premium') || name.includes('prenium') || name.includes('creator')) + return 'premium' + return null +} + const computeCoinPackPricing = (packs = []) => { if (!Array.isArray(packs) || !packs.length) { return {} @@ -160,6 +187,11 @@ function CoinPackCard({ pack, selected, pricingDetail, onSelect, staticDiscountP ? `-${discountPercent}% vs pack de base` : null + const packKey = getCoinPackKey(pack) + const details = packKey ? COIN_PACK_DETAILS[packKey] : null + const displayName = details?.label || pack.name + const creditsText = details?.creditsDisplay + return ( - {/*{pricingDetail?.isBestValue ? (*/} - {/* */} - {/* Meilleure offre*/} - {/* */} - {/*) : null}*/} - + {creditsText ? ( + {creditsText} + ) : ( + + )} + {discountLabel ? ( ) : null} - {pack?.name ? {pack.name} : null} + {displayName} + {details?.disclaimer ? ( + {details.disclaimer} + ) : null} {formattedPrice ? {formattedPrice} : null} @@ -486,6 +521,20 @@ const styles = StyleSheet.create({ fontSize: 20, color: Palette.white, }, + coinAmountCustom: { + fontFamily: FONT_FAMILY.InterBold, + fontSize: 20, + color: Palette.white, + textAlign: 'center', + }, + packDisclaimer: { + fontFamily: FONT_FAMILY.InterRegular, + fontSize: 10, + color: 'rgba(255, 255, 255, 0.6)', + fontStyle: 'italic', + textAlign: 'center', + marginTop: 4, + }, packName: { fontFamily: FONT_FAMILY.InterMedium, fontSize: 16, diff --git a/src/screens/Subscriptions.js b/src/screens/Subscriptions.js index 29dbd41..0d3a09e 100644 --- a/src/screens/Subscriptions.js +++ b/src/screens/Subscriptions.js @@ -240,6 +240,33 @@ const PLAN_DISPLAY_NAME_BY_KEY = { premium: 'Play Backer Gold', } +const COIN_PACK_DETAILS = { + starter: { + label: 'Pack starter', + creditsDisplay: '50 Crédits', + disclaimer: '*Non-Eligible au concours Chanson/Vidéo', + }, + medium: { + label: 'Pack Medium', + creditsDisplay: '100 Crédits + 50 offerts', + disclaimer: '*Non-Eligible au concours Chanson/Vidéo', + }, + premium: { + label: 'Pack Premium', + creditsDisplay: '150 Crédits + 100 offerts', + disclaimer: '*Non-Eligible au concours Chanson/Vidéo', + }, +} + +const getCoinPackKey = (pack) => { + const name = (pack?.name || '').toLowerCase() + if (name.includes('starter')) return 'starter' + if (name.includes('medium')) return 'medium' + if (name.includes('premium') || name.includes('prenium') || name.includes('creator')) + return 'premium' + return null +} + const PLAN_DETAILS = { starter: { creditsLabel: '50 Crédits / Mois', @@ -746,15 +773,28 @@ export default function Subscriptions() { const price = formatCurrency(rawAmount, pack.currency) // Assuming pack structure: { id, name, unitAmount/amount, currency, metadata: { coins: 100 } } const coins = Number(pack.metadata?.coins || 0) + + const packKey = getCoinPackKey(pack) + const details = packKey ? COIN_PACK_DETAILS[packKey] : null + const displayName = details?.label || pack.name + const creditsText = details?.creditsDisplay + return ( - - {pack.name} - + + {displayName} + {creditsText ? ( + {creditsText} + ) : ( + + )} + {details?.disclaimer ? ( + {details.disclaimer} + ) : null}