@tap-payments/os-micro-frontend-shared 0.0.99-amount-fix-1 → 0.0.99-amount-fix-4
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.
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
export const BASE_URL = (_a = (isSAOCI ? 'https://mw-os.tap.com.sa' : import.meta.env.VITE_MW_BASE_URL)) !== null && _a !== void 0 ? _a : import.meta.env.VITE_BASE_URL;
|
|
1
|
+
const IS_SA_OCI = import.meta.env.VITE_DEPLOYMENT_REGION === 'sa-oci';
|
|
2
|
+
export const BASE_URL = IS_SA_OCI ? 'https://mw-os.tap.com.sa' : import.meta.env.VITE_BASE_URL;
|
|
4
3
|
export const API_URL = `${BASE_URL}/api`;
|
|
5
4
|
export const ENV = import.meta.env.VITE_ENV;
|
|
6
5
|
export const TEST_SECRET_KEY = import.meta.env.VITE_TEST_FIXED_SK;
|
|
@@ -10,22 +10,14 @@ export declare const isIntegerAmount: (charge: number) => boolean;
|
|
|
10
10
|
export declare const isDecimalWithOneDigit: (charge: number) => boolean;
|
|
11
11
|
export declare const hasOnlyOneDigitAfterDecimal: (charge: number) => boolean;
|
|
12
12
|
export declare const formatCurrencyWithInput: (charge: number, selectedCurrency: CurrencyCodes) => string;
|
|
13
|
-
export declare function formatAmount(amount: number,
|
|
13
|
+
export declare function formatAmount(amount: number, decimal?: number): {
|
|
14
14
|
integerAmount: string;
|
|
15
15
|
decimalAmount: string;
|
|
16
16
|
fullAmount: string;
|
|
17
|
-
raw: {
|
|
18
|
-
integer: number;
|
|
19
|
-
decimal: number;
|
|
20
|
-
};
|
|
21
17
|
};
|
|
22
18
|
export declare function formatAmountWithCurrency(amount?: number, currency?: string): {
|
|
23
19
|
integerAmount: string;
|
|
24
20
|
decimalAmount: string;
|
|
25
21
|
fullAmount: string;
|
|
26
|
-
raw: {
|
|
27
|
-
integer: number;
|
|
28
|
-
decimal: number;
|
|
29
|
-
};
|
|
30
22
|
};
|
|
31
23
|
export declare const getSupportedCurrencies: (currencies: Currency[]) => Currency[];
|
package/build/utils/currency.js
CHANGED
|
@@ -66,22 +66,24 @@ function getRawAmount(integer, decimalStr, isNegative) {
|
|
|
66
66
|
decimal,
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
|
-
export function formatAmount(amount,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
69
|
+
export function formatAmount(amount, decimal = 2) {
|
|
70
|
+
const num = parseFloat(amount.toString());
|
|
71
|
+
if (isNaN(num)) {
|
|
72
|
+
const [integerAmount, decimalAmount] = (0).toFixed(decimal).split('.');
|
|
73
|
+
const fullAmount = `${integerAmount}.${decimalAmount}`;
|
|
74
|
+
return {
|
|
75
|
+
integerAmount,
|
|
76
|
+
decimalAmount,
|
|
77
|
+
fullAmount,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const fixedNumber = num.toFixed(decimal);
|
|
81
|
+
const [integerPart, decimalPart] = fixedNumber.split('.');
|
|
82
|
+
const formattedInteger = parseInt(integerPart).toLocaleString();
|
|
80
83
|
return {
|
|
81
|
-
integerAmount:
|
|
82
|
-
decimalAmount:
|
|
83
|
-
fullAmount
|
|
84
|
-
raw,
|
|
84
|
+
integerAmount: formattedInteger,
|
|
85
|
+
decimalAmount: decimalPart,
|
|
86
|
+
fullAmount: `${formattedInteger}.${decimalPart}`,
|
|
85
87
|
};
|
|
86
88
|
}
|
|
87
89
|
export function formatAmountWithCurrency(amount = 0, currency = '') {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tap-payments/os-micro-frontend-shared",
|
|
3
3
|
"description": "Shared components and utilities for Tap Payments micro frontends",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "0.0.99-amount-fix-4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "build/index.js",
|
|
7
7
|
"module": "build/index.js",
|