Skip to content

Commit

Permalink
Fixes the logic to showing values with the correct precision.
Browse files Browse the repository at this point in the history
  • Loading branch information
eireland committed Apr 10, 2024
1 parent abf07a0 commit 4830465
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/components/nested-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,16 @@ export const NestedTable = (props: IProps) => {
// determine if it should be parsed as a number.
// Numbers that are whole numbers are treated as integers, so we should ignore the precision.
// Numeric cells that are empty should be treated as empty strings.
const val = (attrTypes[key] !== "numeric" && attrTypes[key] !== null)
|| (values[key] === "")
|| (typeof values[key] !== "number")
? values[key]
: isWholeNumber
? parseInt(values[key],10)
: precision !== undefined
? (parseFloat(values[key])).toFixed(precision)
: (parseFloat(values[key])).toFixed(2); // default to 2 decimal places
const val = attrTypes[key] === "numeric" && values[key] !== ""
? !isNaN(parseFloat(values[key]))
? isWholeNumber
? parseInt(values[key], 10)
: parseFloat(values[key]).toFixed(precision !== undefined ? precision : 2)
: values[key]
: typeof values[key] === "number" && values[key] !== ""
? values[key].toFixed(precision !== undefined ? precision : 2)
: values[key];

if (attrVisibilities[key]) {
return null;
}
Expand Down

0 comments on commit 4830465

Please sign in to comment.