From de5d53bcd3a341d26a71a91b89f04f166f18a376 Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Tue, 24 Dec 2024 13:56:49 +0800 Subject: [PATCH] added nearly complete currencies --- addon/components/currency-select.js | 8 +- .../components/modals/create-or-join-org.hbs | 2 +- addon/utils/get-currency.js | 560 +++++++++++++++++- 3 files changed, 557 insertions(+), 13 deletions(-) diff --git a/addon/components/currency-select.js b/addon/components/currency-select.js index f58e57e..5abda5f 100644 --- a/addon/components/currency-select.js +++ b/addon/components/currency-select.js @@ -15,12 +15,12 @@ export default class CurrencySelectComponent extends Component { let whois = this.currentUser.getOption('whois'); - this.currency = this.args.currency ?? whois?.currency?.code ?? 'USD'; + this.currency = this.args.currency ?? this.args.value ?? whois?.currency?.code ?? 'USD'; this.currencyData = this.args.currencyData ?? getCurrency(this.currency); } @action onChange(currency) { - const { onChange, onCurrencyChange } = this.args; + const { onChange, onCurrencyChange, onSelect } = this.args; this.currency = currency.code; this.currencyData = currency; @@ -29,6 +29,10 @@ export default class CurrencySelectComponent extends Component { onCurrencyChange(currency.code, currency); } + if (typeof onSelect === 'function') { + onSelect(currency.code, currency); + } + if (typeof onChange === 'function') { onChange(currency); } diff --git a/addon/components/modals/create-or-join-org.hbs b/addon/components/modals/create-or-join-org.hbs index b345687..a9966ae 100644 --- a/addon/components/modals/create-or-join-org.hbs +++ b/addon/components/modals/create-or-join-org.hbs @@ -40,7 +40,7 @@ - + {{/if}} diff --git a/addon/utils/get-currency.js b/addon/utils/get-currency.js index 810156f..85518a4 100644 --- a/addon/utils/get-currency.js +++ b/addon/utils/get-currency.js @@ -24,16 +24,40 @@ const currencies = [ symbolPlacement: 'before', }, { - iso2: 'SN', - name: 'West African Economic and Monetary Union', - emoji: '๐Ÿ‡ธ๐Ÿ‡ณ', - code: 'XOF', - title: 'West African CFA Franc', - symbol: 'Fr', - precision: 0, - thousandSeparator: ',', - decimalSeparator: '.', - symbolPlacement: 'before', + iso2: 'AF', + name: 'Afghanistan', + emoji: '๐Ÿ‡ฆ๐Ÿ‡ซ', + code: 'AFN', + title: 'Afghan Afghani', + symbol: 'ุ‹', + precision: 2, + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, + { + iso2: 'AO', + name: 'Angola', + emoji: '๐Ÿ‡ฆ๐Ÿ‡ด', + code: 'AOA', + title: 'Angolan Kwanza', + symbol: 'Kz', + precision: 2, + thousandSeparator: '.', + decimalSeparator: ',', + symbolPlacement: 'before', + }, + { + iso2: 'AZ', + name: 'Azerbaijan', + emoji: '๐Ÿ‡ฆ๐Ÿ‡ฟ', + code: 'AZN', + title: 'Azerbaijani Manat', + symbol: 'โ‚ผ', + precision: 2, + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', }, { code: 'EUR', @@ -46,6 +70,42 @@ const currencies = [ name: 'European Union', emoji: '๐Ÿ‡ช๐Ÿ‡บ', }, + { + iso2: 'XX', + name: 'West African Economic and Monetary Union', + emoji: '๐Ÿ‡ธ๐Ÿ‡ณ', + code: 'XOF', + title: 'West African CFA Franc', + symbol: 'Fr', + precision: 0, + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, + { + iso2: 'XX', + name: 'Central African CFA Franc', + emoji: '๐Ÿ‡จ๐Ÿ‡ฒ', + code: 'XAF', + title: 'Central African CFA Franc', + symbol: 'FCFA', + precision: 0, + thousandSeparator: ',', + decimalSeparator: '', + symbolPlacement: 'before', + }, + { + iso2: 'XX', + name: 'CFP Franc', + emoji: '๐Ÿ‡ต๐Ÿ‡ซ', + code: 'XPF', + title: 'CFP Franc', + symbol: 'Fr', + precision: 0, + thousandSeparator: ',', + decimalSeparator: '', + symbolPlacement: 'before', + }, { iso2: 'AE', name: 'United Arab Emirates', @@ -202,6 +262,18 @@ const currencies = [ decimalSeparator: '.', symbolPlacement: 'before', }, + { + iso2: 'BI', + name: 'Burundi', + emoji: '๐Ÿ‡ง๐Ÿ‡ฎ', + code: 'BIF', + title: 'Burundian Franc', + symbol: 'FBu', + precision: 0, + thousandSeparator: ',', + decimalSeparator: '', // No subunits used + symbolPlacement: 'before', + }, { iso2: 'BW', name: 'Botswana', @@ -226,6 +298,18 @@ const currencies = [ decimalSeparator: '.', symbolPlacement: 'before', }, + { + iso2: 'CL', + name: 'Chile', + emoji: '๐Ÿ‡จ๐Ÿ‡ฑ', + code: 'CLP', + title: 'Chilean Peso', + symbol: 'CLP$', + precision: 0, + thousandSeparator: '.', + decimalSeparator: '', + symbolPlacement: 'before', + }, { iso2: 'CN', name: 'China', @@ -262,6 +346,18 @@ const currencies = [ decimalSeparator: ',', symbolPlacement: 'before', }, + { + iso2: 'CD', + name: 'Democratic Republic of the Congo', + emoji: '๐Ÿ‡จ๐Ÿ‡ฉ', + code: 'CDF', + title: 'Congolese Franc', + symbol: 'FC', + precision: 0, + thousandSeparator: ',', + decimalSeparator: '', // No subunits used + symbolPlacement: 'before', + }, { iso2: 'CR', name: 'Costa Rica', @@ -286,6 +382,18 @@ const currencies = [ decimalSeparator: '.', symbolPlacement: 'before', }, + { + iso2: 'CU', + name: 'Cuba', + emoji: '๐Ÿ‡จ๐Ÿ‡บ', + code: 'CUP', + title: 'Cuban Peso', + symbol: 'CUP$', + precision: 2, + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, { iso2: 'CW', name: 'Curaรงao', @@ -298,6 +406,18 @@ const currencies = [ decimalSeparator: ',', symbolPlacement: 'before', }, + { + iso2: 'CY', + name: 'Cyprus', + emoji: '๐Ÿ‡จ๐Ÿ‡พ', + code: 'CYP', + title: 'Cyprus Pound', + symbol: 'ยฃ', + precision: 2, + thousandSeparator: '.', + decimalSeparator: ',', + symbolPlacement: 'before', + }, { iso2: 'KY', name: 'Cayman Islands', @@ -382,6 +502,30 @@ const currencies = [ decimalSeparator: '.', symbolPlacement: 'before', }, + { + iso2: 'GH', + name: 'Ghana', + emoji: '๐Ÿ‡ฌ๐Ÿ‡ญ', + code: 'GHS', + title: 'Ghanaian Cedi', + symbol: 'GHโ‚ต', + precision: 2, + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, + { + iso2: 'GH', + name: 'Ghana', + emoji: '๐Ÿ‡ฌ๐Ÿ‡ญ', + code: 'GHC', + title: 'Ghana, Cedi', + symbol: 'GHโ‚ต', + precision: 2, + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, { iso2: 'GI', name: 'Gibraltar', @@ -406,6 +550,42 @@ const currencies = [ decimalSeparator: '.', symbolPlacement: 'before', }, + { + iso2: 'GN', + name: 'Guinea', + emoji: '๐Ÿ‡ฌ๐Ÿ‡ณ', + code: 'GNF', + title: 'Guinean Franc', + symbol: 'FG', + precision: 0, + thousandSeparator: ',', + decimalSeparator: '', // No subunits used + symbolPlacement: 'before', + }, + { + iso2: 'GY', + name: 'Guyana', + emoji: '๐Ÿ‡ฌ๐Ÿ‡พ', + code: 'GYD', + title: 'Guyanaese Dollar', + symbol: '$', + precision: 2, + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, + { + iso2: 'HT', + name: 'Haiti', + emoji: '๐Ÿ‡ญ๐Ÿ‡น', + code: 'HTG', + title: 'Haitian Gourde', + symbol: 'G', + precision: 2, + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, { iso2: 'HK', name: 'Hong Kong', @@ -490,6 +670,18 @@ const currencies = [ decimalSeparator: '.', symbolPlacement: 'before', }, + { + iso2: 'IQ', + name: 'Iraq', + emoji: '๐Ÿ‡ฎ๐Ÿ‡ถ', + code: 'IQD', + title: 'Iraqi Dinar', + symbol: 'ุน.ุฏ', + precision: 3, // Iraqi Dinar has three decimal places + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, { iso2: 'IS', name: 'Iceland', @@ -586,6 +778,42 @@ const currencies = [ decimalSeparator: '.', symbolPlacement: 'before', }, + { + iso2: 'KG', + name: 'Kyrgyzstan', + emoji: '๐Ÿ‡ฐ๐Ÿ‡ฌ', + code: 'KGS', + title: 'Kyrgyzstani Som', + symbol: 'ัะพะผ', + precision: 2, + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, + { + iso2: 'LV', + name: 'Latvia', + emoji: '๐Ÿ‡ฑ๐Ÿ‡ป', + code: 'LVL', + title: 'Latvian Lats', + symbol: 'Ls', + precision: 2, + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, + { + iso2: 'LA', + name: 'Laos', + emoji: '๐Ÿ‡ฑ๐Ÿ‡ฆ', + code: 'LAK', + title: 'Lao Kip', + symbol: 'โ‚ญ', + precision: 0, // No subunits used + thousandSeparator: ',', + decimalSeparator: '', // No subunits used + symbolPlacement: 'before', + }, { iso2: 'LB', name: 'Lebanon', @@ -598,6 +826,42 @@ const currencies = [ decimalSeparator: '', symbolPlacement: 'before', }, + { + iso2: 'LS', + name: 'Lesotho', + emoji: '๐Ÿ‡ฑ๐Ÿ‡ธ', + code: 'LSL', + title: 'Lesotho Loti', + symbol: 'M', + precision: 2, + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, + { + iso2: 'LR', + name: 'Liberia', + emoji: '๐Ÿ‡ฑ๐Ÿ‡ท', + code: 'LRD', + title: 'Liberian Dollar', + symbol: '$', + precision: 2, + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, + { + iso2: 'LY', + name: 'Libya', + emoji: '๐Ÿ‡ฑ๐Ÿ‡พ', + code: 'LYD', + title: 'Libyan Dinar', + symbol: 'ู„.ุฏ', + precision: 3, // Libyan Dinar has three decimal places + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, { iso2: 'LI', name: 'Liechtenstein', @@ -610,6 +874,30 @@ const currencies = [ decimalSeparator: '.', symbolPlacement: 'before', }, + { + iso2: 'LT', + name: 'Lithuania', + emoji: '๐Ÿ‡ฑ๐Ÿ‡น', + code: 'LTL', + title: 'Lithuanian Litas', + symbol: ' Lt', + precision: 2, + thousandSeparator: ' ', + decimalSeparator: ',', + symbolPlacement: 'after', + }, + { + iso2: 'MT', + name: 'Malta', + emoji: '๐Ÿ‡ฒ๐Ÿ‡น', + code: 'MTL', + title: 'Maltese Lira', + symbol: 'Lm', + precision: 2, + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, { iso2: 'MX', name: 'Mexico', @@ -622,6 +910,18 @@ const currencies = [ decimalSeparator: '.', symbolPlacement: 'before', }, + { + iso2: 'MZ', + name: 'Mozambique', + emoji: '๐Ÿ‡ฒ๐Ÿ‡ฟ', + code: 'MZM', + title: 'Mozambique Metical', + symbol: 'MT', + precision: 2, + thousandSeparator: '.', + decimalSeparator: ',', + symbolPlacement: 'before', + }, { iso2: 'MK', name: 'North Macedonia', @@ -634,6 +934,30 @@ const currencies = [ decimalSeparator: ',', symbolPlacement: 'before', }, + { + iso2: 'MW', + name: 'Malawi', + emoji: '๐Ÿ‡ฒ๐Ÿ‡ผ', + code: 'MWK', + title: 'Malawian Kwacha', + symbol: 'MK', + precision: 2, + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, + { + iso2: 'MV', + name: 'Maldives', + emoji: '๐Ÿ‡ฒ๐Ÿ‡ป', + code: 'MVR', + title: 'Maldivian Rufiyaa', + symbol: 'Rf', + precision: 2, + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, { iso2: 'MN', name: 'Mongolia', @@ -646,6 +970,30 @@ const currencies = [ decimalSeparator: '', symbolPlacement: 'before', }, + { + iso2: 'MD', + name: 'Moldova', + emoji: '๐Ÿ‡ฒ๐Ÿ‡ฉ', + code: 'MDL', + title: 'Moldovan Leu', + symbol: 'L', + precision: 2, + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, + { + iso2: 'MO', + name: 'Macau', + emoji: '๐Ÿ‡ฒ๐Ÿ‡ด', + code: 'MOP', + title: 'Macanese Pataca', + symbol: 'P', + precision: 2, + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, { iso2: 'MU', name: 'Mauritius', @@ -670,6 +1018,30 @@ const currencies = [ decimalSeparator: '.', symbolPlacement: 'before', }, + { + iso2: 'MM', + name: 'Myanmar', + emoji: '๐Ÿ‡ฒ๐Ÿ‡ฒ', + code: 'MMK', + title: 'Burmese Kyat', + symbol: 'K', + precision: 2, + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, + { + iso2: 'NA', + name: 'Namibia', + emoji: '๐Ÿ‡ณ๐Ÿ‡ฆ', + code: 'NAD', + title: 'Namibian Dollar', + symbol: '$', + precision: 2, + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, { iso2: 'NG', name: 'Nigeria', @@ -778,6 +1150,18 @@ const currencies = [ decimalSeparator: ',', symbolPlacement: 'before', }, + { + iso2: 'RO', + name: 'Romania', + emoji: '๐Ÿ‡ท๐Ÿ‡ด', + code: 'ROL', + title: 'Romania, Old Leu', + symbol: null, + precision: 2, + thousandSeparator: '.', + decimalSeparator: ',', + symbolPlacement: 'before', + }, { iso2: 'RU', name: 'Russia', @@ -814,6 +1198,30 @@ const currencies = [ decimalSeparator: '.', symbolPlacement: 'before', }, + { + iso2: 'SK', + name: 'Slovakia', + emoji: '๐Ÿ‡ธ๐Ÿ‡ฐ', + code: 'SKK', + title: 'Slovak Koruna', + symbol: ' SKK', + precision: 2, + thousandSeparator: ' ', + decimalSeparator: ',', + symbolPlacement: 'after', + }, + { + iso2: 'SI', + name: 'Slovenia', + emoji: '๐Ÿ‡ธ๐Ÿ‡ฎ', + code: 'SIT', + title: 'Slovenia, Tolar', + symbol: null, + precision: 2, + thousandSeparator: '.', + decimalSeparator: ',', + symbolPlacement: 'before', + }, { iso2: 'SV', name: 'El Salvador', @@ -874,6 +1282,18 @@ const currencies = [ decimalSeparator: '.', symbolPlacement: 'before', }, + { + iso2: 'TJ', + name: 'Tajikistan', + emoji: '๐Ÿ‡น๐Ÿ‡ฏ', + code: 'TJS', + title: 'Tajikistani Somoni', + symbol: 'ะ…ะœ', + precision: 2, + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, { iso2: 'TW', name: 'Taiwan', @@ -922,6 +1342,42 @@ const currencies = [ decimalSeparator: ',', symbolPlacement: 'before', }, + { + iso2: 'TM', + name: 'Turkmenistan', + emoji: '๐Ÿ‡น๐Ÿ‡ฒ', + code: 'TMT', + title: 'Turkmenistani Manat', + symbol: 'm', + precision: 2, + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, + { + iso2: 'TN', + name: 'Tunisia', + emoji: '๐Ÿ‡น๐Ÿ‡ณ', + code: 'TND', + title: 'Tunisian Dinar', + symbol: 'ุฏ.ุช', + precision: 3, // Tunisian Dinar has three decimal places + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, + { + iso2: 'TT', + name: 'Trinidad and Tobago', + emoji: '๐Ÿ‡น๐Ÿ‡น', + code: 'TTD', + title: 'Trinidad and Tobago Dollar', + symbol: '$', + precision: 2, + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, { iso2: 'TZ', name: 'Tanzania', @@ -970,6 +1426,54 @@ const currencies = [ decimalSeparator: '/', symbolPlacement: 'before', }, + { + iso2: 'UY', + name: 'Uruguay', + emoji: '๐Ÿ‡บ๐Ÿ‡พ', + code: 'UYU', + title: 'Peso Uruguayo', + symbol: '$U ', + precision: 2, + thousandSeparator: '.', + decimalSeparator: ',', + symbolPlacement: 'before', + }, + { + iso2: 'UZ', + name: 'Uzbekistan', + emoji: '๐Ÿ‡บ๐Ÿ‡ฟ', + code: 'UZS', + title: 'Uzbekistani Som', + symbol: 'ะปะฒ', + precision: 2, + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, + { + iso2: 'VE', + name: 'Venezuela', + emoji: '๐Ÿ‡ป๐Ÿ‡ช', + code: 'VEB', + title: 'Venezuela, Bolivar', + symbol: 'Bs.', + precision: 2, + thousandSeparator: '.', + decimalSeparator: ',', + symbolPlacement: 'before', + }, + { + iso2: 'VE', + name: 'Venezuela', + emoji: '๐Ÿ‡ป๐Ÿ‡ช', + code: 'VEF', + title: 'Venezuela Bolivares Fuertes', + symbol: 'Bs.', + precision: 2, + thousandSeparator: '.', + decimalSeparator: ',', + symbolPlacement: 'before', + }, { iso2: 'VN', name: 'Vietnam', @@ -994,6 +1498,18 @@ const currencies = [ decimalSeparator: '', symbolPlacement: 'before', }, + { + iso2: 'WS', + name: 'Samoa', + emoji: '๐Ÿ‡ผ๐Ÿ‡ธ', + code: 'WST', + title: 'Samoan Tala', + symbol: 'T', + precision: 2, + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, { iso2: 'ZA', name: 'South Africa', @@ -1006,6 +1522,30 @@ const currencies = [ decimalSeparator: '.', symbolPlacement: 'before', }, + { + iso2: 'ZM', + name: 'Zambia', + emoji: '๐Ÿ‡ฟ๐Ÿ‡ฒ', + code: 'ZMW', + title: 'Zambian Kwacha', + symbol: 'ZK', + precision: 2, + thousandSeparator: ',', + decimalSeparator: '.', + symbolPlacement: 'before', + }, + { + iso2: 'ZW', + name: 'Zimbabwe', + emoji: '๐Ÿ‡ฟ๐Ÿ‡ผ', + code: 'ZWD', + title: 'Zimbabwe Dollar', + symbol: 'Z$', + precision: 2, + thousandSeparator: ' ', + decimalSeparator: '.', + symbolPlacement: 'before', + }, ]; export default function getCurrency(code) {