mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-28 05:14:12 +03:00
86b55b0f81
refs https://github.com/TryGhost/Team/issues/1037 Adds new free tier card with option to add custom description and benefits for free tier, behind the tiers beta flag. Also: - updates formatting of tier prices - changes "Free" section to "Default" - updates price formatting of membership tiers in admin - updates currency code handling for product card - updates default paid product handling Co-authored-by: Djordje Vlaisavljevic <dzvlais@gmail.com> Co-authored-by: Peter Zimon <peter.zimon@gmail.com>
165 lines
6.7 KiB
JavaScript
165 lines
6.7 KiB
JavaScript
export const currencies = [
|
||
{isoCode: 'USD', name: 'United States dollar'},
|
||
{isoCode: 'EUR', name: 'Euro'},
|
||
{isoCode: 'GBP', name: 'Pound sterling'},
|
||
{isoCode: 'AUD', name: 'Australian dollar'},
|
||
{isoCode: 'CAD', name: 'Canadian dollar'},
|
||
{isoCode: 'AED', name: 'United Arab Emirates dirham'},
|
||
{isoCode: 'AFN', name: 'Afghan afghani'},
|
||
{isoCode: 'ALL', name: 'Albanian lek'},
|
||
{isoCode: 'AMD', name: 'Armenian dram'},
|
||
{isoCode: 'ANG', name: 'Netherlands Antillean guilder'},
|
||
{isoCode: 'AOA', name: 'Angolan kwanza'},
|
||
{isoCode: 'ARS', name: 'Argentine peso'},
|
||
{isoCode: 'AWG', name: 'Aruban florin'},
|
||
{isoCode: 'AZN', name: 'Azerbaijani manat'},
|
||
{isoCode: 'BAM', name: 'Bosnia and Herzegovina convertible mark'},
|
||
{isoCode: 'BBD', name: 'Barbados dollar'},
|
||
{isoCode: 'BDT', name: 'Bangladeshi taka'},
|
||
{isoCode: 'BGN', name: 'Bulgarian lev'},
|
||
{isoCode: 'BMD', name: 'Bermudian dollar'},
|
||
{isoCode: 'BND', name: 'Brunei dollar'},
|
||
{isoCode: 'BOB', name: 'Boliviano'},
|
||
{isoCode: 'BRL', name: 'Brazilian real'},
|
||
{isoCode: 'BSD', name: 'Bahamian dollar'},
|
||
{isoCode: 'BWP', name: 'Botswana pula'},
|
||
{isoCode: 'BZD', name: 'Belize dollar'},
|
||
{isoCode: 'CDF', name: 'Congolese franc'},
|
||
{isoCode: 'CHF', name: 'Swiss franc'},
|
||
{isoCode: 'CNY', name: 'Chinese yuan'},
|
||
{isoCode: 'COP', name: 'Colombian peso'},
|
||
{isoCode: 'CRC', name: 'Costa Rican colon'},
|
||
{isoCode: 'CVE', name: 'Cape Verdean escudo'},
|
||
{isoCode: 'CZK', name: 'Czech koruna'},
|
||
{isoCode: 'DKK', name: 'Danish krone'},
|
||
{isoCode: 'DOP', name: 'Dominican peso'},
|
||
{isoCode: 'DZD', name: 'Algerian dinar'},
|
||
{isoCode: 'EGP', name: 'Egyptian pound'},
|
||
{isoCode: 'ETB', name: 'Ethiopian birr'},
|
||
{isoCode: 'FJD', name: 'Fiji dollar'},
|
||
{isoCode: 'FKP', name: 'Falkland Islands pound'},
|
||
{isoCode: 'GEL', name: 'Georgian lari'},
|
||
{isoCode: 'GIP', name: 'Gibraltar pound'},
|
||
{isoCode: 'GMD', name: 'Gambian dalasi'},
|
||
{isoCode: 'GTQ', name: 'Guatemalan queztal'},
|
||
{isoCode: 'GYD', name: 'Guyanese dollar'},
|
||
{isoCode: 'HKD', name: 'Hong Kong dollar'},
|
||
{isoCode: 'HNL', name: 'Honduran lempira'},
|
||
{isoCode: 'HRK', name: 'Croation kuna'},
|
||
{isoCode: 'HTG', name: 'Haitian gourde'},
|
||
{isoCode: 'HUF', name: 'Hungarian forint'},
|
||
{isoCode: 'IDR', name: 'Indonesian rupiah'},
|
||
{isoCode: 'ILS', name: 'Israeli new shekel'},
|
||
{isoCode: 'INR', name: 'Indian rupee'},
|
||
{isoCode: 'ISK', name: 'Icelandic króna'},
|
||
{isoCode: 'JMD', name: 'Jamaican dollar'},
|
||
{isoCode: 'KES', name: 'Kenyan shilling'},
|
||
{isoCode: 'KGS', name: 'Kyrgyzstani som'},
|
||
{isoCode: 'KHR', name: 'Cambodian riel'},
|
||
{isoCode: 'KYD', name: 'Cayman Islands dollar'},
|
||
{isoCode: 'KZT', name: 'Kazakhstani tenge'},
|
||
{isoCode: 'LAK', name: 'Lao kip'},
|
||
{isoCode: 'LBP', name: 'Lebanese pound'},
|
||
{isoCode: 'LKR', name: 'Sri Lankan rupee'},
|
||
{isoCode: 'LRD', name: 'Liberian dollar'},
|
||
{isoCode: 'LSL', name: 'Lesotho loti'},
|
||
{isoCode: 'MAD', name: 'Moroccan dirham'},
|
||
{isoCode: 'MDL', name: 'Moldovan leu'},
|
||
{isoCode: 'MKD', name: 'Macedonian denar'},
|
||
{isoCode: 'MMK', name: 'Myanmar kyat'},
|
||
{isoCode: 'MNT', name: 'Mongolian tögrög'},
|
||
{isoCode: 'MOP', name: 'Macanese pataca'},
|
||
{isoCode: 'MRO', name: 'Mauritanian ouguiya'},
|
||
{isoCode: 'MUR', name: 'Mauritian rupee'},
|
||
{isoCode: 'MVR', name: 'Maldivian rufiyaa'},
|
||
{isoCode: 'MWK', name: 'Malawian kwacha'},
|
||
{isoCode: 'MXN', name: 'Mexican peso'},
|
||
{isoCode: 'MYR', name: 'Malaysian ringgit'},
|
||
{isoCode: 'MZN', name: 'Mozambican metical'},
|
||
{isoCode: 'NAD', name: 'Namibian dollar'},
|
||
{isoCode: 'NGN', name: 'Nigerian naira'},
|
||
{isoCode: 'NIO', name: 'Nicaraguan córdoba'},
|
||
{isoCode: 'NOK', name: 'Norwegian krone'},
|
||
{isoCode: 'NPR', name: 'Nepalese rupee'},
|
||
{isoCode: 'NZD', name: 'New Zealand dollar'},
|
||
{isoCode: 'PAB', name: 'Panamanian balboa'},
|
||
{isoCode: 'PEN', name: 'Peruvian sol'},
|
||
{isoCode: 'PGK', name: 'Papua New Guinean kina'},
|
||
{isoCode: 'PHP', name: 'Philippine peso'},
|
||
{isoCode: 'PKR', name: 'Pakistani rupee'},
|
||
{isoCode: 'PLN', name: 'Polish złoty'},
|
||
{isoCode: 'QAR', name: 'Qatari riyal'},
|
||
{isoCode: 'RON', name: 'Romanian leu'},
|
||
{isoCode: 'RSD', name: 'Serbian dinar'},
|
||
{isoCode: 'RUB', name: 'Russian ruble'},
|
||
{isoCode: 'SAR', name: 'Saudi riyal'},
|
||
{isoCode: 'SBD', name: 'Solomon Islands dollar'},
|
||
{isoCode: 'SCR', name: 'Seychelles rupee'},
|
||
{isoCode: 'SEK', name: 'Swedish krona'},
|
||
{isoCode: 'SGD', name: 'Singapore dollar'},
|
||
{isoCode: 'SHP', name: 'Saint Helena pound'},
|
||
{isoCode: 'SLL', name: 'Sierra Leonean leone'},
|
||
{isoCode: 'SOS', name: 'Somali shilling'},
|
||
{isoCode: 'SRD', name: 'Surinamese dollar'},
|
||
{isoCode: 'STD', name: 'São Tomé and Príncipe dobra'},
|
||
{isoCode: 'SZL', name: 'Salvadoran colón'},
|
||
{isoCode: 'THB', name: 'Thai baht'},
|
||
{isoCode: 'TJS', name: 'Tajikistani somoni'},
|
||
{isoCode: 'TOP', name: 'Tongan paʻanga'},
|
||
{isoCode: 'TRY', name: 'Turkish lira'},
|
||
{isoCode: 'TTD', name: 'Trinidad and Tobago dollar'},
|
||
{isoCode: 'TWD', name: 'New Taiwan dollar'},
|
||
{isoCode: 'TZS', name: 'Tanzanian shilling'},
|
||
{isoCode: 'UAH', name: 'Ukrainian hryvnia'},
|
||
{isoCode: 'UYU', name: 'Uruguayan peso'},
|
||
{isoCode: 'UZS', name: 'Uzbekistan som'},
|
||
{isoCode: 'WST', name: 'Samoan tala'},
|
||
{isoCode: 'XCD', name: 'East Caribbean dollar'},
|
||
{isoCode: 'YER', name: 'Yemeni rial'},
|
||
{isoCode: 'ZAR', name: 'South African rand'},
|
||
{isoCode: 'ZMW', name: 'Zambian kwacha'}
|
||
];
|
||
|
||
export function getSymbol(currency) {
|
||
if (!currency) {
|
||
return '';
|
||
}
|
||
return Intl.NumberFormat('en', {currency, style: 'currency'}).format(0).replace(/[\d\s.]/g, '');
|
||
}
|
||
|
||
// We currently only support decimal currencies
|
||
export function getNonDecimal(amount/*, currency*/) {
|
||
return amount / 100;
|
||
}
|
||
|
||
export function getCurrencyOptions() {
|
||
const noOfTopCurrencies = 5;
|
||
|
||
const topCurrencies = currencies.slice(0, noOfTopCurrencies).map((currency) => {
|
||
return {
|
||
value: currency.isoCode.toLowerCase(),
|
||
label: `${currency.isoCode} - ${currency.name}`,
|
||
isoCode: currency.isoCode
|
||
};
|
||
});
|
||
|
||
const otherCurrencies = currencies.slice(noOfTopCurrencies, currencies.length).map((currency) => {
|
||
return {
|
||
value: currency.isoCode.toLowerCase(),
|
||
label: `${currency.isoCode} - ${currency.name}`,
|
||
isoCode: currency.isoCode
|
||
};
|
||
});
|
||
|
||
return [
|
||
{
|
||
groupName: '—',
|
||
options: topCurrencies
|
||
},
|
||
{
|
||
groupName: '—',
|
||
options: otherCurrencies
|
||
}
|
||
];
|
||
}
|