فهرست منبع

Merge pull request #18686 from overleaf/jel-plans-page-currency

[web] Move `currency` check to `_getRecommendedCurrency`

GitOrigin-RevId: afadd492a2e1db9c91fac027eb3c9783194ff169
Jessica Lawshe 2 سال پیش
والد
کامیت
d28e58a2fc
1فایلهای تغییر یافته به همراه16 افزوده شده و 11 حذف شده
  1. 16 11
      services/web/app/src/Features/Subscription/SubscriptionController.js

+ 16 - 11
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 latamCountryBannerDetails = await getLatamCountryBannerDetails(req, res)
-  if (recommendedCurrency && currency == null) {
-    currency = recommendedCurrency
-  }
+  const {
+    currency,
+    recommendedCurrency,
+    countryCode,
+    geoPricingLATAMTestVariant,
+  } = await _getRecommendedCurrency(req, res)
 
+  const latamCountryBannerDetails = await getLatamCountryBannerDetails(req, res)
   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,