@tap-payments/os-micro-frontend-shared 0.0.152 → 0.0.155-jsonviewer-fix-v1

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.
@@ -15,6 +15,10 @@ export const JsonViewerDialogContextProvider = ({ children }) => {
15
15
  if (jsonViewerList.some((item) => item.json.id === jsonViewer.json.id)) {
16
16
  return;
17
17
  }
18
+ const requestData = jsonViewer.json.request_body;
19
+ if (requestData && !jsonViewer.requestJson) {
20
+ jsonViewer.requestJson = requestData;
21
+ }
18
22
  (_a = jsonViewer === null || jsonViewer === void 0 ? void 0 : jsonViewer.json) === null || _a === void 0 ? true : delete _a.request_body;
19
23
  setJsonViewerList((prev) => [...prev, jsonViewer]);
20
24
  }, [jsonViewerList]);
@@ -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 { fullAmount } = formatAmountWithCurrency(amount, currency);
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, decimalPlaces?: 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[];
@@ -55,33 +55,24 @@ export const formatCurrencyWithInput = (charge, selectedCurrency) => {
55
55
  }
56
56
  return chargeString;
57
57
  };
58
- function buildFormattedAmount(integer, decimal) {
59
- return Number(decimal) > 0 ? `${integer}.${decimal}` : integer;
60
- }
61
- function getRawAmount(integer, decimalStr, isNegative) {
62
- const sign = isNegative ? -1 : 1;
63
- const decimal = Number(`0.${decimalStr}`) * sign;
64
- return {
65
- integer: integer * sign,
66
- decimal,
67
- };
68
- }
69
- export function formatAmount(amount, decimalPlaces = 2) {
70
- var _a;
71
- const isNegative = amount < 0;
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: formattedIntegerAmount,
82
- decimalAmount: decimalStr,
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.152",
4
+ "version": "0.0.155-jsonviewer-fix-v1",
5
5
  "type": "module",
6
6
  "main": "build/index.js",
7
7
  "module": "build/index.js",