diff --git a/cope2n-fe/src/components/report-detail/report-table.tsx b/cope2n-fe/src/components/report-detail/report-table.tsx index 0156358..66bfa6a 100644 --- a/cope2n-fe/src/components/report-detail/report-table.tsx +++ b/cope2n-fe/src/components/report-detail/report-table.tsx @@ -125,8 +125,7 @@ const ReportTable: React.FC = () => { const isAbnormal = ensureMin(record['IMEI Acc'], 0.95); return ( - {record['IMEI Acc'] && - formatPercent(Number(record['IMEI Acc']))} + {formatPercent(Number(record['IMEI Acc']))} ); }, @@ -139,8 +138,7 @@ const ReportTable: React.FC = () => { const isAbnormal = ensureMin(record['Avg. Accuracy'], 0.95); return ( - {record['Avg. Accuracy'] && - formatPercent(Number(record['Avg. Accuracy']))} + {formatPercent(Number(record['Avg. Accuracy']))} ); }, @@ -153,8 +151,7 @@ const ReportTable: React.FC = () => { const isAbnormal = ensureMax(record['Avg. OCR Processing Time'], 2); return ( - {record['Avg. OCR Processing Time'] && - Number(record['Avg. OCR Processing Time'])?.toFixed(2)} + {Number(record['Avg. OCR Processing Time'])?.toFixed(2)} ); }, diff --git a/cope2n-fe/src/utils/metric-format.ts b/cope2n-fe/src/utils/metric-format.ts index 79a6340..02f290e 100644 --- a/cope2n-fe/src/utils/metric-format.ts +++ b/cope2n-fe/src/utils/metric-format.ts @@ -1,5 +1,5 @@ -export const formatPercent = (value: number, floatingPoint: number = 1) => { - if (value === null || value === undefined) { +export const formatPercent = (value: any, floatingPoint: number = 1, maskZero: boolean = false) => { + if (value === null || value === undefined || (value === 0 && maskZero)) { return '-'; } if (value < 100.0) { @@ -13,6 +13,7 @@ export const ensureMin = ( min: number, skipZero: boolean = true, ) => { + if (formatPercent(value) == '-') return false; if (skipZero && value === 0) { return false; } @@ -27,6 +28,7 @@ export const ensureMax = ( max: number, skipZero: boolean = true, ) => { + if (formatPercent(value) == '-') return false; if (skipZero && value === 0) { return false; }