@simonarcher/fika-types 1.0.87 → 1.0.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/currencyUtils.d.ts +10 -0
- package/dist/currencyUtils.js +85 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps ISO 3166-1 alpha-2 country codes to ISO 4217 currency codes
|
|
3
|
+
* Used to automatically determine currency for shops based on their country code
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Gets the currency code for a given country code
|
|
7
|
+
* @param countryCode ISO 3166-1 alpha-2 country code (e.g., "NL", "US", "ZA")
|
|
8
|
+
* @returns ISO 4217 currency code (e.g., "EUR", "USD", "ZAR"), defaults to "EUR" if not found
|
|
9
|
+
*/
|
|
10
|
+
export declare function getCurrencyFromCountryCode(countryCode: string | undefined | null): string;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Maps ISO 3166-1 alpha-2 country codes to ISO 4217 currency codes
|
|
4
|
+
* Used to automatically determine currency for shops based on their country code
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.getCurrencyFromCountryCode = getCurrencyFromCountryCode;
|
|
8
|
+
const COUNTRY_TO_CURRENCY = {
|
|
9
|
+
// Eurozone countries
|
|
10
|
+
NL: 'EUR', // Netherlands
|
|
11
|
+
BE: 'EUR', // Belgium
|
|
12
|
+
DE: 'EUR', // Germany
|
|
13
|
+
FR: 'EUR', // France
|
|
14
|
+
IT: 'EUR', // Italy
|
|
15
|
+
ES: 'EUR', // Spain
|
|
16
|
+
PT: 'EUR', // Portugal
|
|
17
|
+
AT: 'EUR', // Austria
|
|
18
|
+
FI: 'EUR', // Finland
|
|
19
|
+
IE: 'EUR', // Ireland
|
|
20
|
+
GR: 'EUR', // Greece
|
|
21
|
+
LU: 'EUR', // Luxembourg
|
|
22
|
+
MT: 'EUR', // Malta
|
|
23
|
+
CY: 'EUR', // Cyprus
|
|
24
|
+
SK: 'EUR', // Slovakia
|
|
25
|
+
SI: 'EUR', // Slovenia
|
|
26
|
+
EE: 'EUR', // Estonia
|
|
27
|
+
LV: 'EUR', // Latvia
|
|
28
|
+
LT: 'EUR', // Lithuania
|
|
29
|
+
HR: 'EUR', // Croatia
|
|
30
|
+
// Major coffee shop countries
|
|
31
|
+
US: 'USD', // United States
|
|
32
|
+
ZA: 'ZAR', // South Africa
|
|
33
|
+
GB: 'GBP', // United Kingdom
|
|
34
|
+
UK: 'GBP', // United Kingdom (alternative code)
|
|
35
|
+
AU: 'AUD', // Australia
|
|
36
|
+
CA: 'CAD', // Canada
|
|
37
|
+
JP: 'JPY', // Japan
|
|
38
|
+
CH: 'CHF', // Switzerland
|
|
39
|
+
SE: 'SEK', // Sweden
|
|
40
|
+
NO: 'NOK', // Norway
|
|
41
|
+
DK: 'DKK', // Denmark
|
|
42
|
+
PL: 'PLN', // Poland
|
|
43
|
+
CZ: 'CZK', // Czech Republic
|
|
44
|
+
NZ: 'NZD', // New Zealand
|
|
45
|
+
SG: 'SGD', // Singapore
|
|
46
|
+
HK: 'HKD', // Hong Kong
|
|
47
|
+
KR: 'KRW', // South Korea
|
|
48
|
+
CN: 'CNY', // China
|
|
49
|
+
IN: 'INR', // India
|
|
50
|
+
BR: 'BRL', // Brazil
|
|
51
|
+
MX: 'MXN', // Mexico
|
|
52
|
+
AR: 'ARS', // Argentina
|
|
53
|
+
CL: 'CLP', // Chile
|
|
54
|
+
CO: 'COP', // Colombia
|
|
55
|
+
PE: 'PEN', // Peru
|
|
56
|
+
TH: 'THB', // Thailand
|
|
57
|
+
MY: 'MYR', // Malaysia
|
|
58
|
+
ID: 'IDR', // Indonesia
|
|
59
|
+
PH: 'PHP', // Philippines
|
|
60
|
+
VN: 'VND', // Vietnam
|
|
61
|
+
TW: 'TWD', // Taiwan
|
|
62
|
+
TR: 'TRY', // Turkey
|
|
63
|
+
IL: 'ILS', // Israel
|
|
64
|
+
AE: 'AED', // United Arab Emirates
|
|
65
|
+
SA: 'SAR', // Saudi Arabia
|
|
66
|
+
RU: 'RUB', // Russia
|
|
67
|
+
IS: 'ISK', // Iceland
|
|
68
|
+
HU: 'HUF', // Hungary
|
|
69
|
+
RO: 'RON', // Romania
|
|
70
|
+
BG: 'BGN', // Bulgaria
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Gets the currency code for a given country code
|
|
74
|
+
* @param countryCode ISO 3166-1 alpha-2 country code (e.g., "NL", "US", "ZA")
|
|
75
|
+
* @returns ISO 4217 currency code (e.g., "EUR", "USD", "ZAR"), defaults to "EUR" if not found
|
|
76
|
+
*/
|
|
77
|
+
function getCurrencyFromCountryCode(countryCode) {
|
|
78
|
+
if (!countryCode) {
|
|
79
|
+
return 'EUR'; // Default to EUR
|
|
80
|
+
}
|
|
81
|
+
// Normalize to uppercase for lookup
|
|
82
|
+
const normalizedCode = countryCode.toUpperCase().trim();
|
|
83
|
+
// Return mapped currency or default to EUR
|
|
84
|
+
return COUNTRY_TO_CURRENCY[normalizedCode] || 'EUR';
|
|
85
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -42,3 +42,5 @@ __exportStar(require("./rewards"), exports);
|
|
|
42
42
|
__exportStar(require("./shopAnalytics"), exports);
|
|
43
43
|
// Export all shop correction-related types
|
|
44
44
|
__exportStar(require("./shopCorrections"), exports);
|
|
45
|
+
// Export currency utilities
|
|
46
|
+
__exportStar(require("./currencyUtils"), exports);
|