Show all values

This commit is contained in:
Viet Anh Nguyen 2024-03-07 16:08:44 +07:00
parent b3fd8c22c9
commit dc9f7c00d6
2 changed files with 7 additions and 8 deletions

View File

@ -125,8 +125,7 @@ const ReportTable: React.FC = () => {
const isAbnormal = ensureMin(record['IMEI Acc'], 0.95); const isAbnormal = ensureMin(record['IMEI Acc'], 0.95);
return ( return (
<span style={{ color: isAbnormal ? 'red' : '' }}> <span style={{ color: isAbnormal ? 'red' : '' }}>
{record['IMEI Acc'] && {formatPercent(Number(record['IMEI Acc']))}
formatPercent(Number(record['IMEI Acc']))}
</span> </span>
); );
}, },
@ -139,8 +138,7 @@ const ReportTable: React.FC = () => {
const isAbnormal = ensureMin(record['Avg. Accuracy'], 0.95); const isAbnormal = ensureMin(record['Avg. Accuracy'], 0.95);
return ( return (
<span style={{ color: isAbnormal ? 'red' : '' }}> <span style={{ color: isAbnormal ? 'red' : '' }}>
{record['Avg. Accuracy'] && {formatPercent(Number(record['Avg. Accuracy']))}
formatPercent(Number(record['Avg. Accuracy']))}
</span> </span>
); );
}, },
@ -153,8 +151,7 @@ const ReportTable: React.FC = () => {
const isAbnormal = ensureMax(record['Avg. OCR Processing Time'], 2); const isAbnormal = ensureMax(record['Avg. OCR Processing Time'], 2);
return ( return (
<span style={{ color: isAbnormal ? 'red' : '' }}> <span style={{ color: isAbnormal ? 'red' : '' }}>
{record['Avg. OCR Processing Time'] && {Number(record['Avg. OCR Processing Time'])?.toFixed(2)}
Number(record['Avg. OCR Processing Time'])?.toFixed(2)}
</span> </span>
); );
}, },

View File

@ -1,5 +1,5 @@
export const formatPercent = (value: number, floatingPoint: number = 1) => { export const formatPercent = (value: any, floatingPoint: number = 1, maskZero: boolean = false) => {
if (value === null || value === undefined) { if (value === null || value === undefined || (value === 0 && maskZero)) {
return '-'; return '-';
} }
if (value < 100.0) { if (value < 100.0) {
@ -13,6 +13,7 @@ export const ensureMin = (
min: number, min: number,
skipZero: boolean = true, skipZero: boolean = true,
) => { ) => {
if (formatPercent(value) == '-') return false;
if (skipZero && value === 0) { if (skipZero && value === 0) {
return false; return false;
} }
@ -27,6 +28,7 @@ export const ensureMax = (
max: number, max: number,
skipZero: boolean = true, skipZero: boolean = true,
) => { ) => {
if (formatPercent(value) == '-') return false;
if (skipZero && value === 0) { if (skipZero && value === 0) {
return false; return false;
} }