diff --git a/dev-client/src/model/soilId/actions/soilDataDiff.ts b/dev-client/src/model/soilId/actions/soilDataDiff.ts index 62ce4bbe4..78540b6ed 100644 --- a/dev-client/src/model/soilId/actions/soilDataDiff.ts +++ b/dev-client/src/model/soilId/actions/soilDataDiff.ts @@ -25,23 +25,20 @@ import { import { DEPTH_DEPENDENT_SOIL_DATA_UPDATE_FIELDS, DEPTH_INTERVAL_UPDATE_FIELDS, - DepthDependentUpdateField, - DepthIntervalUpdateField, SOIL_DATA_UPDATE_FIELDS, - SoilDataUpdateField, } from 'terraso-mobile-client/model/soilId/actions/soilDataActionFields'; import {depthIntervalKey} from 'terraso-mobile-client/model/soilId/soilIdFunctions'; export const getChangedSoilDataFields = ( curr: SoilData, prev?: SoilData, -): Record => { +): Partial => { return diffFields(SOIL_DATA_UPDATE_FIELDS, curr, prev); }; -export type DepthIntervalChanges = { +export type DepthIntervalChanges = { depthInterval: DepthInterval; - changedFields: Record; + changedFields: Partial; }; export const getDeletedDepthIntervals = ( @@ -63,7 +60,7 @@ export const getDeletedDepthIntervals = ( export const getChangedDepthIntervals = ( curr: SoilData, prev?: SoilData, -): DepthIntervalChanges[] => { +): DepthIntervalChanges[] => { const prevIntervals = indexDepthIntervals(prev?.depthIntervals ?? []); const diffs = curr.depthIntervals.map(di => { return { @@ -81,14 +78,14 @@ export const getChangedDepthIntervals = ( export const getChangedDepthIntervalFields = ( curr: SoilDataDepthInterval, prev?: SoilDataDepthInterval, -): Record => { +): Partial => { return diffFields(DEPTH_INTERVAL_UPDATE_FIELDS, curr, prev); }; export const getChangedDepthDependentData = ( curr: SoilData, prev?: SoilData, -): DepthIntervalChanges[] => { +): DepthIntervalChanges[] => { const prevData = indexDepthIntervals(prev?.depthDependentData ?? []); const diffs = curr.depthDependentData.map(dd => { return { @@ -105,7 +102,7 @@ export const getChangedDepthDependentData = ( export const getChangedDepthDependentFields = ( curr: DepthDependentSoilData, prev?: DepthDependentSoilData, -): Record => { +): Partial => { return diffFields(DEPTH_DEPENDENT_SOIL_DATA_UPDATE_FIELDS, curr, prev); }; @@ -113,7 +110,7 @@ export const diffFields = ( fields: F[], curr: T, prev?: T, -): Record => { +): Partial => { let changedFields: (keyof T)[]; if (!prev) { changedFields = fields; @@ -123,7 +120,7 @@ export const diffFields = ( return Object.fromEntries( changedFields.map(field => [field, curr[field]]), - ) as Record; + ) as Partial; }; export const indexDepthIntervals = (