Skip to content

Commit df5537f

Browse files
vishalshrm539Sharmatumms2021389
authored
Fixed issues identified during adoption testing (#523)
* Fixed issues identified during adoption testing --------- Co-authored-by: Sharma <[email protected]> Co-authored-by: tumms2021389 <[email protected]>
1 parent 3f73c0b commit df5537f

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

packages/react-sdk-components/src/components/designSystemExtension/CaseSummaryFields/CaseSummaryFields.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ export default function CaseSummaryFields(props: CaseSummaryFieldsProps) {
223223

224224
// Whenever theFieldsToRender changes, update theFieldsAsGridItems that's used during render
225225
useEffect(() => {
226-
const arGridItems = theFieldsToRender.map((field: any) => {
226+
const arGridItems = theFieldsToRender?.map((field: any) => {
227227
// display the field when either visibility property doesn't exist or is true(if exists)
228228
if (field.config.visibility === undefined || field.config.visibility === true) {
229229
return (

packages/react-sdk-components/src/components/helpers/formatters/Currency.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import { getLocale } from './common';
22
import CurrencyMap from './CurrencyMap';
33

4+
const isValidValue = value => {
5+
return value !== null && value !== undefined && value !== '';
6+
};
7+
48
// eslint-disable-next-line @typescript-eslint/no-unused-vars
59
function NumberFormatter(value, { locale = 'en-US', decPlaces = 2, style = '', currency = 'USD' } = {}): string {
610
const currentLocale: string | undefined = getLocale(locale);
7-
if (value !== null && value !== undefined) {
11+
if (isValidValue(value)) {
812
return Number(value).toLocaleString(currentLocale, { minimumFractionDigits: decPlaces, maximumFractionDigits: decPlaces });
913
}
1014
return value;
@@ -16,7 +20,7 @@ function CurrencyFormatter(
1620
): string {
1721
const currentLocale: string | undefined = getLocale(locale);
1822
let formattedValue: string = value;
19-
if (value !== null && value !== undefined && value !== '') {
23+
if (isValidValue(value)) {
2024
formattedValue = NumberFormatter(value, { locale: currentLocale, decPlaces, style, currency });
2125

2226
// For currency other than EUR, we need to determine the country code from currency code
@@ -55,7 +59,7 @@ function CurrencyFormatter(
5559

5660
function SymbolFormatter(value, { symbol = '$', suffix = true, locale = 'en-US' } = {}): string {
5761
let formattedValue: string = value;
58-
if (value !== null && value !== undefined) {
62+
if (isValidValue(value)) {
5963
formattedValue = NumberFormatter(value, { locale });
6064
return suffix ? `${formattedValue}${symbol}` : `${symbol}${formattedValue}`;
6165
}
@@ -68,5 +72,6 @@ export default {
6872
Decimal: (value, options) => NumberFormatter(value, options),
6973
'Decimal-Auto': (value, options) => NumberFormatter(value, { ...options, decPlaces: Number.isInteger(value) ? 0 : 2 }),
7074
Integer: (value, options) => NumberFormatter(value, { ...options, decPlaces: 0 }),
71-
Percentage: (value, options) => SymbolFormatter(value, { ...options, symbol: '%' })
75+
Percentage: (value, options) => SymbolFormatter(value, { ...options, symbol: '%' }),
76+
isValidValue
7277
};

0 commit comments

Comments
 (0)