Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export default function CaseSummaryFields(props: CaseSummaryFieldsProps) {

// Whenever theFieldsToRender changes, update theFieldsAsGridItems that's used during render
useEffect(() => {
const arGridItems = theFieldsToRender.map((field: any) => {
const arGridItems = theFieldsToRender?.map((field: any) => {
// display the field when either visibility property doesn't exist or is true(if exists)
if (field.config.visibility === undefined || field.config.visibility === true) {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { getLocale } from './common';
import CurrencyMap from './CurrencyMap';

const isValidValue = value => {
return value !== null && value !== undefined && value !== '';
};

// eslint-disable-next-line @typescript-eslint/no-unused-vars
function NumberFormatter(value, { locale = 'en-US', decPlaces = 2, style = '', currency = 'USD' } = {}): string {
const currentLocale: string | undefined = getLocale(locale);
if (value !== null && value !== undefined) {
if (isValidValue(value)) {
return Number(value).toLocaleString(currentLocale, { minimumFractionDigits: decPlaces, maximumFractionDigits: decPlaces });
}
return value;
Expand All @@ -16,7 +20,7 @@ function CurrencyFormatter(
): string {
const currentLocale: string | undefined = getLocale(locale);
let formattedValue: string = value;
if (value !== null && value !== undefined && value !== '') {
if (isValidValue(value)) {
formattedValue = NumberFormatter(value, { locale: currentLocale, decPlaces, style, currency });

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

function SymbolFormatter(value, { symbol = '$', suffix = true, locale = 'en-US' } = {}): string {
let formattedValue: string = value;
if (value !== null && value !== undefined) {
if (isValidValue(value)) {
formattedValue = NumberFormatter(value, { locale });
return suffix ? `${formattedValue}${symbol}` : `${symbol}${formattedValue}`;
}
Expand All @@ -68,5 +72,6 @@ export default {
Decimal: (value, options) => NumberFormatter(value, options),
'Decimal-Auto': (value, options) => NumberFormatter(value, { ...options, decPlaces: Number.isInteger(value) ? 0 : 2 }),
Integer: (value, options) => NumberFormatter(value, { ...options, decPlaces: 0 }),
Percentage: (value, options) => SymbolFormatter(value, { ...options, symbol: '%' })
Percentage: (value, options) => SymbolFormatter(value, { ...options, symbol: '%' }),
isValidValue
};