mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
e97c56b105
GitOrigin-RevId: d6dedf7af04c79cef6b9cd39f5496610ffc52938
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
import getMeta from '../../../utils/meta'
|
|
|
|
// plan: 'collaborator' or 'professional'
|
|
// the rest of available arguments can be seen in the groupPlans value
|
|
export function createLocalizedGroupPlanPrice({
|
|
plan,
|
|
licenseSize,
|
|
currency,
|
|
usage,
|
|
}) {
|
|
const groupPlans = getMeta('ol-groupPlans')
|
|
const currencySymbols = getMeta('ol-currencySymbols')
|
|
const priceInCents =
|
|
groupPlans[usage][plan][currency][licenseSize].price_in_cents
|
|
|
|
const price = priceInCents / 100
|
|
const perUserPrice = price / parseInt(licenseSize)
|
|
|
|
const strPrice = price.toFixed()
|
|
let strPerUserPrice = ''
|
|
|
|
if (Number.isInteger(perUserPrice)) {
|
|
strPerUserPrice = String(perUserPrice)
|
|
} else {
|
|
strPerUserPrice = perUserPrice.toFixed(2)
|
|
}
|
|
|
|
const currencySymbol = currencySymbols[currency]
|
|
|
|
switch (currencySymbol) {
|
|
case 'Fr':
|
|
return {
|
|
localizedPrice: `${currencySymbol} ${strPrice}`,
|
|
localizedPerUserPrice: `${currencySymbol} ${strPerUserPrice}`,
|
|
}
|
|
case 'kr':
|
|
return {
|
|
localizedPrice: `${strPrice} ${currencySymbol}`,
|
|
localizedPerUserPrice: `${strPerUserPrice} ${currencySymbol}`,
|
|
}
|
|
default: {
|
|
return {
|
|
localizedPrice: `${currencySymbol}${strPrice}`,
|
|
localizedPerUserPrice: `${currencySymbol}${strPerUserPrice}`,
|
|
}
|
|
}
|
|
}
|
|
}
|