From 5aa7355b0feecf1a675ba7cfb6b92d0435138b2f Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Mon, 14 Jul 2025 23:08:18 +0100 Subject: [PATCH] Enhance PropertyChanges component to handle cases where both old and new values are absent, and improve rendering logic for displaying property changes. --- .../Dashboard/common/PropertyChanges.jsx | 45 ++++++++++++------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/src/components/Dashboard/common/PropertyChanges.jsx b/src/components/Dashboard/common/PropertyChanges.jsx index 61eaa03..8b342ce 100644 --- a/src/components/Dashboard/common/PropertyChanges.jsx +++ b/src/components/Dashboard/common/PropertyChanges.jsx @@ -8,7 +8,7 @@ import ArrowRightIcon from '../../Icons/ArrowRightIcon' const { Text } = Typography const PropertyChanges = ({ type, value }) => { - if (!value || !value.new) { + if (!value || (!value.new && !value.old)) { return n/a } @@ -18,7 +18,15 @@ const PropertyChanges = ({ type, value }) => { if (Object.prototype.hasOwnProperty.call(obj, key)) { const val = obj[key] const newKey = prefix ? `${prefix}.${key}` : key - if (val && typeof val === 'object' && !Array.isArray(val)) { + + // Don't flatten keys that are "state" or "netGross" + if ( + val && + typeof val === 'object' && + !Array.isArray(val) && + key !== 'state' && + key !== 'netGross' + ) { flattenObject(val, newKey, res) } else { res[newKey] = val @@ -34,7 +42,6 @@ const PropertyChanges = ({ type, value }) => { ...flatOld, ...flatNew } - console.log('combined', combinedChanges) return ( {Object.keys(combinedChanges).map((key) => { @@ -46,19 +53,25 @@ const PropertyChanges = ({ type, value }) => { return ( - - - - - + {value?.old ? ( + + ) : null} + {value?.old && value?.new ? ( + + + + ) : null} + {value?.new ? ( + + ) : null} )