diff --git a/src/constants.ts b/src/constants.ts index e0970b74..da054569 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -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 }, @@ -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[]; diff --git a/src/selectors.test.ts b/src/selectors.test.ts index c088886d..bf2978cc 100644 --- a/src/selectors.test.ts +++ b/src/selectors.test.ts @@ -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 { @@ -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, @@ -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>), }; diff --git a/src/selectors.ts b/src/selectors.ts index 42104139..b7500d7c 100644 --- a/src/selectors.ts +++ b/src/selectors.ts @@ -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 { @@ -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 };