1
0
Fork 0
mirror of https://github.com/overleaf/overleaf.git synced 2025-04-14 18:34:17 +00:00

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

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

GitOrigin-RevId: afadd492a2e1db9c91fac027eb3c9783194ff169
This commit is contained in:
Jessica Lawshe 2024-06-05 10:19:45 -05:00 committed by Copybot
parent 6c9d4fb522
commit d28e58a2fc

View file

@ -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,