@tap-payments/os-micro-frontend-shared 0.0.152 → 0.0.155-jsonviewer-fix-v2
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.
|
@@ -7,7 +7,6 @@ export const JsonViewerDialogContextProvider = ({ children }) => {
|
|
|
7
7
|
const [isWindowMinimized, setIsWindowMinimized] = useState(false);
|
|
8
8
|
const [windowOrder, setWindowOrder] = useState(1);
|
|
9
9
|
const handleJsonViewerDialogOpen = useCallback((jsonViewer) => {
|
|
10
|
-
var _a;
|
|
11
10
|
if (jsonViewerList.length === 7) {
|
|
12
11
|
alert('Maximum allowed active Json Viewer is 7 per table.');
|
|
13
12
|
return;
|
|
@@ -15,8 +14,14 @@ export const JsonViewerDialogContextProvider = ({ children }) => {
|
|
|
15
14
|
if (jsonViewerList.some((item) => item.json.id === jsonViewer.json.id)) {
|
|
16
15
|
return;
|
|
17
16
|
}
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const jsonCopy = Object.assign({}, jsonViewer.json);
|
|
18
|
+
const requestData = jsonCopy.request_body;
|
|
19
|
+
const processedJsonViewer = {
|
|
20
|
+
json: jsonCopy,
|
|
21
|
+
requestJson: jsonViewer.requestJson || requestData || undefined,
|
|
22
|
+
};
|
|
23
|
+
delete processedJsonViewer.json.request_body;
|
|
24
|
+
setJsonViewerList((prev) => [...prev, processedJsonViewer]);
|
|
20
25
|
}, [jsonViewerList]);
|
|
21
26
|
const handleJsonViewerDialogClose = (index) => {
|
|
22
27
|
setJsonViewerList((prev) => prev.filter((_, idx) => index !== idx));
|
|
@@ -20,8 +20,7 @@ import { FlagIcon } from '../style';
|
|
|
20
20
|
function AmountCell(_a) {
|
|
21
21
|
var { conversionType, amount, currency, tooltipLabel, amountTooltipLabel, isTextShown, tableMode } = _a, props = __rest(_a, ["conversionType", "amount", "currency", "tooltipLabel", "amountTooltipLabel", "isTextShown", "tableMode"]);
|
|
22
22
|
const icon = currency && _jsx(FlagIcon, { src: getCurrenciesIcon(currency), alt: "customer icon" });
|
|
23
|
-
const {
|
|
24
|
-
const [integerAmount, decimalAmount] = fullAmount.toString().split('.');
|
|
23
|
+
const { integerAmount, decimalAmount } = formatAmountWithCurrency(amount, currency);
|
|
25
24
|
return (_jsx(TableCell, Object.assign({}, props, { children: _jsxs(AmountCellContainer, { children: [_jsx(Tooltip, Object.assign({ title: tooltipLabel || '' }, { children: conversionType && (_jsx(ConversionBadge, Object.assign({ tableMode: tableMode, className: "conversion-type" }, { children: conversionType }))) })), _jsx(Tooltip, Object.assign({ title: _jsx(CurrencyIcon, { currency: currency }) }, { children: isTextShown ? _jsx("span", {}) : _jsx(FlagContainer, { children: icon }) })), _jsx(Tooltip, Object.assign({ title: amountTooltipLabel }, { children: _jsx(CurrencySpan, Object.assign({ tableMode: tableMode }, { children: amount !== undefined ? (_jsxs(_Fragment, { children: [_jsx("span", { children: _jsx(CurrencyIcon, { currency: currency, fontSize: 10 }) }), ' ', integerAmount, decimalAmount && (_jsxs(_Fragment, { children: [".", _jsx(DecimalSpan, { children: decimalAmount })] }))] })) : (_jsx("span", { children: "-" })) })) }))] }) })));
|
|
26
25
|
}
|
|
27
26
|
export default AmountCell;
|
|
@@ -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
|
@@ -55,33 +55,24 @@ export const formatCurrencyWithInput = (charge, selectedCurrency) => {
|
|
|
55
55
|
}
|
|
56
56
|
return chargeString;
|
|
57
57
|
};
|
|
58
|
-
function
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
amount = Math.abs(amount);
|
|
73
|
-
const integerAmount = Math.floor(amount);
|
|
74
|
-
let decimalStr = (amount - integerAmount).toString().split('.')[1] || '0';
|
|
75
|
-
decimalStr = decimalStr.padEnd(decimalPlaces, '0').slice(0, decimalPlaces);
|
|
76
|
-
const formattedIntegerAmount = Intl.NumberFormat('en-US').format(integerAmount);
|
|
77
|
-
const decimalStrWithoutRounding = (_a = amount.toString().split('.')[1]) === null || _a === void 0 ? void 0 : _a.slice(0, decimalPlaces);
|
|
78
|
-
const fullAmount = buildFormattedAmount(formattedIntegerAmount, decimalStrWithoutRounding);
|
|
79
|
-
const raw = getRawAmount(integerAmount, decimalStr, isNegative);
|
|
58
|
+
export function formatAmount(amount, decimal = 2) {
|
|
59
|
+
const num = parseFloat(amount.toString());
|
|
60
|
+
if (isNaN(num)) {
|
|
61
|
+
const [integerAmount, decimalAmount] = (0).toFixed(decimal).split('.');
|
|
62
|
+
const fullAmount = `${integerAmount}.${decimalAmount}`;
|
|
63
|
+
return {
|
|
64
|
+
integerAmount,
|
|
65
|
+
decimalAmount,
|
|
66
|
+
fullAmount,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const fixedNumber = num.toFixed(decimal);
|
|
70
|
+
const [integerPart, decimalPart] = fixedNumber.split('.');
|
|
71
|
+
const formattedInteger = parseInt(integerPart).toLocaleString();
|
|
80
72
|
return {
|
|
81
|
-
integerAmount:
|
|
82
|
-
decimalAmount:
|
|
83
|
-
fullAmount
|
|
84
|
-
raw,
|
|
73
|
+
integerAmount: formattedInteger,
|
|
74
|
+
decimalAmount: decimalPart,
|
|
75
|
+
fullAmount: `${formattedInteger}.${decimalPart}`,
|
|
85
76
|
};
|
|
86
77
|
}
|
|
87
78
|
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": "0.0.
|
|
4
|
+
"version": "0.0.155-jsonviewer-fix-v2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "build/index.js",
|
|
7
7
|
"module": "build/index.js",
|