Skip to content

Commit

Permalink
feat: Update depth presets for Capri (#732)
Browse files Browse the repository at this point in the history
Commits: 
* feat: Use new depth presets for Capri

* refactor: Rename BLM_STANDARD to BLM

* chore: bump client-shared commit hash
  • Loading branch information
knipec authored Jul 11, 2024
1 parent e1b4e4d commit 0fd354a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"munsell": "^1.1.5",
"react": "18.2.0",
"react-redux": "^8.1.3",
"terraso-backend": "github:techmatters/terraso-backend#b542062",
"terraso-backend": "github:techmatters/terraso-backend#10de1414a43d651af3db55fbac521495d0e2976f",
"uuid": "^10.0.0"
},
"scripts": {
Expand Down
21 changes: 10 additions & 11 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ import { fromEntries, mapEntries } from 'terraso-client-shared/utils';

export const DEPTH_INTERVAL_PRESETS = mapEntries(
{
LANDPKS: [
{ start: 0, end: 10 },
{ start: 10, end: 20 },
{ start: 20, end: 50 },
{ start: 50, end: 70 },
{ start: 70, end: 100 },
{ start: 100, end: 200 },
],
NRCS: [
{ start: 0, end: 5 },
{ start: 5, end: 15 },
Expand All @@ -47,10 +39,17 @@ export const DEPTH_INTERVAL_PRESETS = mapEntries(
{ start: 60, end: 100 },
{ start: 100, end: 200 },
],
BLM: [
{ start: 0, end: 1 },
{ start: 1, end: 10 },
{ start: 10, end: 20 },
{ start: 20, end: 50 },
{ start: 50, end: 70 },
],
} as const,
depthIntervals =>
depthIntervals.map(depthInterval => ({ label: '', depthInterval })),
) satisfies Record<'LANDPKS' | 'NRCS', readonly LabelledDepthInterval[]>;
) satisfies Record<'NRCS' | 'BLM', readonly LabelledDepthInterval[]>;

export const DEFAULT_ENABLED_SOIL_PIT_METHODS: SoilPitMethod[] = [
'soilTexture',
Expand Down Expand Up @@ -83,12 +82,12 @@ export const DEFAULT_PROJECT_SETTINGS: ProjectSoilSettings = {
]),
),
soilPitRequired: true,
depthIntervalPreset: 'LANDPKS',
depthIntervalPreset: 'NRCS',
depthIntervals: [],
};

export const DEFAULT_SOIL_DATA: SoilData = {
depthDependentData: [],
depthIntervals: [],
depthIntervalPreset: 'LANDPKS',
depthIntervalPreset: 'NRCS',
};
8 changes: 4 additions & 4 deletions src/selectors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const createSoilData = (
[site.id]: {
depthDependentData: [],
depthIntervals: [],
depthIntervalPreset: 'LANDPKS',
depthIntervalPreset: 'NRCS',
...defaults,
},
};
Expand All @@ -147,7 +147,7 @@ const createProjectSettings = (
return {
[project.id]: {
// carbonatesRequired: false,
depthIntervalPreset: 'LANDPKS',
depthIntervalPreset: 'NRCS',
depthIntervals: [],
// electricalConductivityRequired: false,
// landUseLandCoverRequired: false,
Expand Down Expand Up @@ -402,7 +402,7 @@ test('select predefined project selector', () => {
const site = generateSite({ project });
const soilData = createSoilData(site);
const projectSettings = createProjectSettings(project, {
depthIntervalPreset: 'LANDPKS',
depthIntervalPreset: 'NRCS',
});

const aggregatedIntervals = renderSelectorHook(
Expand All @@ -416,7 +416,7 @@ test('select predefined project selector', () => {
expect(
aggregatedIntervals.map(({ interval: { depthInterval } }) => depthInterval),
).toStrictEqual(
DEPTH_INTERVAL_PRESETS['LANDPKS'].map(({ depthInterval }) => depthInterval),
DEPTH_INTERVAL_PRESETS['NRCS'].map(({ depthInterval }) => depthInterval),
);
});

Expand Down
4 changes: 2 additions & 2 deletions src/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ export const selectUserRoleProject = createSelector(

const projectIntervals = (settings: ProjectSoilSettings) => {
switch (settings.depthIntervalPreset) {
case 'LANDPKS':
case 'NRCS':
case 'BLM':
return DEPTH_INTERVAL_PRESETS[settings.depthIntervalPreset];
case 'CUSTOM':
return settings.depthIntervals;
Expand All @@ -237,8 +237,8 @@ const projectIntervals = (settings: ProjectSoilSettings) => {

const sitePresetIntervals = (soilData: SoilData) => {
switch (soilData.depthIntervalPreset) {
case 'LANDPKS':
case 'NRCS':
case 'BLM':
return DEPTH_INTERVAL_PRESETS[soilData.depthIntervalPreset];
default:
return [];
Expand Down
2 changes: 1 addition & 1 deletion src/soilId/soilIdTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ export const surfaceCracks = [
export type ProjectDepthIntervalPreset =
SoilIdProjectSoilSettingsDepthIntervalPresetChoices;
export const DEPTH_PRESETS = [
'LANDPKS',
'NRCS',
'BLM',
'CUSTOM',
'NONE',
] as const satisfies readonly ProjectDepthIntervalPreset[];
Expand Down

0 comments on commit 0fd354a

Please sign in to comment.