Try to avoid errors formatting non-numbers

This commit is contained in:
2022-09-07 11:19:15 -05:00
parent 1413e6c8d3
commit 4266ed1690
4 changed files with 26 additions and 4 deletions

View File

@ -32,6 +32,7 @@ import React, {useState} from "react";
import MDBox from "components/MDBox"; import MDBox from "components/MDBox";
import {ProcessSummaryLine} from "qqq/pages/process-run/model/ProcessSummaryLine"; import {ProcessSummaryLine} from "qqq/pages/process-run/model/ProcessSummaryLine";
import QClient from "qqq/utils/QClient"; import QClient from "qqq/utils/QClient";
import QValueUtils from "qqq/utils/QValueUtils";
interface Props interface Props
{ {
@ -66,7 +67,7 @@ function QProcessSummaryResults({
processValues?.recordCount !== undefined && sourceTableMetaData && ( processValues?.recordCount !== undefined && sourceTableMetaData && (
<ListItem sx={{my: 2}}> <ListItem sx={{my: 2}}>
<ListItemText primaryTypographyProps={{fontSize: 16}}> <ListItemText primaryTypographyProps={{fontSize: 16}}>
{processValues.recordCount.toLocaleString()} {QValueUtils.getFormattedNumber(processValues.recordCount)}
{" "} {" "}
{sourceTableMetaData.label} {sourceTableMetaData.label}
{" "} {" "}

View File

@ -133,7 +133,7 @@ function QValidationReview({
processValues?.recordCount !== undefined && sourceTableMetaData && ( processValues?.recordCount !== undefined && sourceTableMetaData && (
<ListItem sx={{my: 2}}> <ListItem sx={{my: 2}}>
<ListItemText primaryTypographyProps={{fontSize: 16}}> <ListItemText primaryTypographyProps={{fontSize: 16}}>
{`Input: ${processValues.recordCount.toLocaleString()} ${sourceTableMetaData?.label} record${processValues.recordCount === 1 ? "" : "s"}.`} {`Input: ${QValueUtils.getFormattedNumber(processValues.recordCount)} ${sourceTableMetaData?.label} record${processValues.recordCount === 1 ? "" : "s"}.`}
</ListItemText> </ListItemText>
</ListItem> </ListItem>
) )
@ -189,7 +189,7 @@ function QValidationReview({
<ListItem sx={{my: 2}}> <ListItem sx={{my: 2}}>
<ListItemText primaryTypographyProps={{fontSize: 16}}> <ListItemText primaryTypographyProps={{fontSize: 16}}>
Validation complete on Validation complete on
{` ${processValues.recordCount.toLocaleString()} ${sourceTableMetaData?.label} `} {` ${QValueUtils.getFormattedNumber(processValues.recordCount)} ${sourceTableMetaData?.label} `}
records. records.
</ListItemText> </ListItemText>
</ListItem> </ListItem>

View File

@ -32,6 +32,7 @@ import Tooltip from "@mui/material/Tooltip";
import React from "react"; import React from "react";
import {Link} from "react-router-dom"; import {Link} from "react-router-dom";
import MDBox from "components/MDBox"; import MDBox from "components/MDBox";
import QValueUtils from "qqq/utils/QValueUtils";
/******************************************************************************* /*******************************************************************************
** Entity that corresponds to qqq backend's ProcessSummaryLine - with methods ** Entity that corresponds to qqq backend's ProcessSummaryLine - with methods
@ -89,7 +90,7 @@ export class ProcessSummaryLine
<Icon fontSize="medium" sx={{mr: 1}} color={this.getColor()}>{this.getIcon(isResultScreen)}</Icon> <Icon fontSize="medium" sx={{mr: 1}} color={this.getColor()}>{this.getIcon(isResultScreen)}</Icon>
<ListItemText primaryTypographyProps={{fontSize: 16}}> <ListItemText primaryTypographyProps={{fontSize: 16}}>
{/* work hard to prevent the icon from falling down to the next line by itself... */} {/* work hard to prevent the icon from falling down to the next line by itself... */}
{`${this.count.toLocaleString()} ${messageWords.join(" ")} `} {`${QValueUtils.getFormattedNumber(this.count)} ${messageWords.join(" ")} `}
{ {
(linkTag) ? ( (linkTag) ? (
<span style={{whiteSpace: "nowrap"}}> <span style={{whiteSpace: "nowrap"}}>

View File

@ -64,6 +64,26 @@ class QValueUtils
return (displayValue); return (displayValue);
} }
public static getFormattedNumber(n: number): string
{
try
{
if(n !== null && n !== undefined)
{
return (n.toLocaleString());
}
else
{
return ("");
}
}
catch(e)
{
return (String(n));
}
}
public static breakTextIntoLines(value: string): JSX.Element public static breakTextIntoLines(value: string): JSX.Element
{ {