mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-14 12:04:46 +00:00
Merge pull request #18713 from overleaf/jel-group-plan-modal-defaults
[web] Move group modal defaults for plans page to function GitOrigin-RevId: 0ebce884f9e984b50318742765b7a768f259a8db
This commit is contained in:
parent
d28e58a2fc
commit
8fe46feffb
1 changed files with 23 additions and 17 deletions
|
@ -32,6 +32,28 @@ const validGroupPlanModalOptions = {
|
|||
usage: groupPlanModalOptions.usages.map(item => item.code),
|
||||
}
|
||||
|
||||
function _getGroupPlanModalDefaults(req, currency) {
|
||||
function getDefault(param, category, defaultValue) {
|
||||
const v = req.query && req.query[param]
|
||||
if (v && validGroupPlanModalOptions[category].includes(v)) {
|
||||
return v
|
||||
}
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
let defaultGroupPlanModalCurrency = 'USD'
|
||||
if (validGroupPlanModalOptions.currency.includes(currency)) {
|
||||
defaultGroupPlanModalCurrency = currency
|
||||
}
|
||||
|
||||
return {
|
||||
plan_code: getDefault('plan', 'plan_code', 'collaborator'),
|
||||
size: getDefault('number', 'size', '2'),
|
||||
currency: getDefault('currency', 'currency', defaultGroupPlanModalCurrency),
|
||||
usage: getDefault('usage', 'usage', 'enterprise'),
|
||||
}
|
||||
}
|
||||
|
||||
async function plansPage(req, res) {
|
||||
const websiteRedesignPlansAssignment =
|
||||
await SplitTestHandler.promises.getAssignment(
|
||||
|
@ -58,26 +80,10 @@ async function plansPage(req, res) {
|
|||
} = 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)) {
|
||||
return v
|
||||
}
|
||||
return defaultValue
|
||||
}
|
||||
const groupPlanModalDefaults = _getGroupPlanModalDefaults(req, currency)
|
||||
|
||||
const currentView = 'annual'
|
||||
|
||||
let defaultGroupPlanModalCurrency = 'USD'
|
||||
if (validGroupPlanModalOptions.currency.includes(currency)) {
|
||||
defaultGroupPlanModalCurrency = currency
|
||||
}
|
||||
const groupPlanModalDefaults = {
|
||||
plan_code: getDefault('plan', 'plan_code', 'collaborator'),
|
||||
size: getDefault('number', 'size', '2'),
|
||||
currency: getDefault('currency', 'currency', defaultGroupPlanModalCurrency),
|
||||
usage: getDefault('usage', 'usage', 'enterprise'),
|
||||
}
|
||||
const plansPageViewSegmentation = {
|
||||
currency: recommendedCurrency,
|
||||
countryCode,
|
||||
|
|
Loading…
Add table
Reference in a new issue