From d28e58a2fcee5503b93660f12f7261cda0cdeb2b Mon Sep 17 00:00:00 2001 From: Jessica Lawshe <5312836+lawshe@users.noreply.github.com> Date: Wed, 5 Jun 2024 10:19:45 -0500 Subject: [PATCH] Merge pull request #18686 from overleaf/jel-plans-page-currency [web] Move `currency` check to `_getRecommendedCurrency` GitOrigin-RevId: afadd492a2e1db9c91fac027eb3c9783194ff169 --- .../Subscription/SubscriptionController.js | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/services/web/app/src/Features/Subscription/SubscriptionController.js b/services/web/app/src/Features/Subscription/SubscriptionController.js index 981e58ee25..6d3811bfff 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionController.js +++ b/services/web/app/src/Features/Subscription/SubscriptionController.js @@ -49,19 +49,15 @@ async function plansPage(req, res) { const language = req.i18n.language || 'en' const plans = SubscriptionViewModelBuilder.buildPlansList() - let currency = null - const queryCurrency = req.query.currency?.toUpperCase() - if (GeoIpLookup.isValidCurrencyParam(queryCurrency)) { - currency = queryCurrency - } - const { recommendedCurrency, countryCode, geoPricingLATAMTestVariant } = - await _getRecommendedCurrency(req, res) + + const { + currency, + recommendedCurrency, + countryCode, + geoPricingLATAMTestVariant, + } = await _getRecommendedCurrency(req, res) const latamCountryBannerDetails = await getLatamCountryBannerDetails(req, res) - if (recommendedCurrency && currency == null) { - currency = recommendedCurrency - } - function getDefault(param, category, defaultValue) { const v = req.query && req.query[param] if (v && validGroupPlanModalOptions[category].includes(v)) { @@ -582,7 +578,16 @@ async function _getRecommendedCurrency(req, res) { recommendedCurrency = GeoIpLookup.DEFAULT_CURRENCY_CODE } + let currency = null + const queryCurrency = req.query.currency?.toUpperCase() + if (queryCurrency && GeoIpLookup.isValidCurrencyParam(queryCurrency)) { + currency = queryCurrency + } else if (recommendedCurrency) { + currency = recommendedCurrency + } + return { + currency, recommendedCurrency, countryCode, geoPricingLATAMTestVariant: assignmentLATAM?.variant,