Refactor normalizeValue function in PerformerResult component for improved value handling.

- Enhanced the normalizeValue function to handle numeric-like strings, converting them to numbers when applicable.
- Maintained existing functionality for trimming and lowercasing non-numeric strings, ensuring consistent value normalization.
This commit is contained in:
KennyG 2026-04-22 12:02:30 -04:00
parent 7a87e15f41
commit db7164d254

View file

@ -21,9 +21,20 @@ interface IPerformerDeltaRow {
}
const normalizeValue = (value: unknown) =>
String(value ?? "")
.trim()
.toLowerCase();
(() => {
const text = String(value ?? "").trim();
if (!text) return "";
const isNumericLike = /^[-+]?(?:\d+\.?\d*|\.\d+)$/.test(text);
if (isNumericLike) {
const numeric = Number(text);
if (!Number.isNaN(numeric)) {
return String(numeric);
}
}
return text.toLowerCase();
})();
const toStringOrNull = (value: unknown) => {
if (value === null || value === undefined) return null;