Skip to content

Commit

Permalink
fix: Rename default soil methods constant
Browse files Browse the repository at this point in the history
  • Loading branch information
David Code Howard committed Feb 2, 2024
1 parent 2cad768 commit 03f6656
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
11 changes: 4 additions & 7 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
import { DepthInterval } from 'terraso-client-shared/graphqlSchema/graphql';
import { SoilPitMethod } from 'terraso-client-shared/soilId/soilIdTypes';

export const DEPTH_INTERVAL_PRESETS: Record<
'LANDPKS' | 'NRCS',
DepthInterval[]
> = {
export const DEPTH_INTERVAL_PRESETS = {
LANDPKS: [
{ start: 0, end: 10 },
{ start: 10, end: 20 },
Expand All @@ -37,10 +34,10 @@ export const DEPTH_INTERVAL_PRESETS: Record<
{ start: 60, end: 100 },
{ start: 100, end: 200 },
],
};
} as const satisfies Record<'LANDPKS' | 'NRCS', readonly DepthInterval[]>;

export const DEFAULT_ENABLED_METHODS: SoilPitMethod[] = [
export const DEFAULT_ENABLED_SOIL_PIT_METHODS = [
'soilTexture',
'soilStructure',
'soilColor',
];
] as const satisfies readonly SoilPitMethod[];
7 changes: 4 additions & 3 deletions src/selectors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
User,
} from 'terraso-client-shared/account/accountSlice';
import {
DEFAULT_ENABLED_METHODS,
DEFAULT_ENABLED_SOIL_PIT_METHODS,
DEPTH_INTERVAL_PRESETS,
} from 'terraso-client-shared/constants';
import {
Expand Down Expand Up @@ -164,7 +164,7 @@ const generateSiteInterval = (
soilTextureEnabled: false,
carbonatesEnabled: false,
...(label !== undefined ? { label } : { label: '' }),
...DEFAULT_ENABLED_METHODS.reduce(
...DEFAULT_ENABLED_SOIL_PIT_METHODS.reduce(
(x, method) => ({
...x,
[methodEnabled(method)]: true,
Expand All @@ -186,7 +186,8 @@ const projectToSiteInterval = (
methodEnabled(method),
projectSettings
? projectSettings[methodRequired(method)]
: false || DEFAULT_ENABLED_METHODS.findIndex(a => a === method) > 0,
: false ||
DEFAULT_ENABLED_SOIL_PIT_METHODS.findIndex(a => a === method) > 0,
]),
) as Record<`${SoilPitMethod}Enabled`, boolean>),
};
Expand Down
4 changes: 2 additions & 2 deletions src/selectors.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createSelector } from '@reduxjs/toolkit';
import { User } from 'terraso-client-shared/account/accountSlice';
import {
DEFAULT_ENABLED_METHODS,
DEFAULT_ENABLED_SOIL_PIT_METHODS,
DEPTH_INTERVAL_PRESETS,
} from 'terraso-client-shared/constants';
import {
Expand Down Expand Up @@ -247,7 +247,7 @@ export const makeSoilDepth = (
methodEnabled(method),
soilSettings
? soilSettings[methodRequired(method)]
: false || DEFAULT_ENABLED_METHODS.includes(method),
: false || DEFAULT_ENABLED_SOIL_PIT_METHODS.includes(method),
]),
) as Record<`${SoilPitMethod}Enabled`, boolean>;
return { ...depthInterval, ...methodsEnabled };
Expand Down

0 comments on commit 03f6656

Please sign in to comment.