diff --git a/src/selectors.ts b/src/selectors.ts index b4e3b0eb..aac1f8f1 100644 --- a/src/selectors.ts +++ b/src/selectors.ts @@ -333,15 +333,18 @@ export const useSiteSoilIntervals = (siteId: string): AggregatedInterval[] => { ); }; -export const selectDepthDependentData = - ({ - siteId, - depthInterval, - }: { - siteId: string; - depthInterval: { depthInterval: DepthInterval }; - }) => - (state: SharedState): DepthDependentSoilData => - selectSoilData(siteId)(state).depthDependentData.find( - sameDepth(depthInterval), - ) ?? { depthInterval: depthInterval.depthInterval }; +export const selectDepthDependentData = ({ + siteId, + depthInterval, +}: { + siteId: string; + depthInterval: { depthInterval: DepthInterval }; +}): ((state: SharedState) => DepthDependentSoilData) => + createSelector( + selectSoilData(siteId), + soilData => + soilData.depthDependentData.find(sameDepth(depthInterval)) ?? + ({ + depthInterval: depthInterval.depthInterval, + } as DepthDependentSoilData), + );