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.
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good

This commit is contained in:
Tom Butcher 2026-07-18 16:28:29 +01:00
parent 2ff3636913
commit 7ca78280b3

View File

@ -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 (
<Descriptions size='small' column={1}>
{Object.keys(combinedChanges).map((key) => {