From 7ca78280b348fe54bc8dc01a10121e9a94e489fe Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Sat, 18 Jul 2026 16:28:29 +0100 Subject: [PATCH] Refactor PropertyChanges component to maintain model references and special value objects. Update key flattening logic to prevent alteration of specific properties, enhancing data integrity during property change handling. --- src/components/Dashboard/common/PropertyChanges.jsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/Dashboard/common/PropertyChanges.jsx b/src/components/Dashboard/common/PropertyChanges.jsx index c00405e..7f5f32d 100644 --- a/src/components/Dashboard/common/PropertyChanges.jsx +++ b/src/components/Dashboard/common/PropertyChanges.jsx @@ -18,11 +18,12 @@ const PropertyChanges = ({ type, value }) => { const val = obj[key] const newKey = prefix ? `${prefix}.${key}` : key - // Don't flatten keys that are "state" or "netGross" + // Keep model references and special value objects intact if ( val && typeof val === 'object' && !Array.isArray(val) && + !Object.prototype.hasOwnProperty.call(val, '_id') && key !== 'state' && key !== 'netGross' ) { @@ -41,6 +42,9 @@ const PropertyChanges = ({ type, value }) => { ...flatOld, ...flatNew } + + console.log(combinedChanges) + return ( {Object.keys(combinedChanges).map((key) => {