From 5c80e5a72102d431dab6bfb85f174d486abea76e Mon Sep 17 00:00:00 2001 From: shrouxm Date: Wed, 20 Nov 2024 10:09:31 -0800 Subject: [PATCH] feat: temporary workaround to cover up inconsistency between list/rank soils --- dev-client/package-lock.json | 6 ++--- dev-client/package.json | 2 +- .../src/model/soilId/soilIdFunctions.ts | 10 ++++--- dev-client/src/model/soilId/soilIdSlice.ts | 26 +++++++++++++------ 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/dev-client/package-lock.json b/dev-client/package-lock.json index 4bc1e09798..97750f3b1a 100644 --- a/dev-client/package-lock.json +++ b/dev-client/package-lock.json @@ -62,7 +62,7 @@ "react-native-svg": "^15.9.0", "react-native-tab-view": "^4.0.1", "reduce-reducers": "^1.0.4", - "terraso-client-shared": "github:techmatters/terraso-client-shared#cdf2161", + "terraso-client-shared": "github:techmatters/terraso-client-shared#ac0867a", "use-debounce": "^10.0.4", "uuid": "^10.0.0", "yup": "^1.4.0" @@ -24162,14 +24162,14 @@ }, "node_modules/terraso-client-shared": { "version": "0.1.0", - "resolved": "git+ssh://git@github.com/techmatters/terraso-client-shared.git#cdf21619c807121a8b02069638ee9a16f7969915", + "resolved": "git+ssh://git@github.com/techmatters/terraso-client-shared.git#ac0867a4be36c50c48bc5a2b94776cefdfd32bc1", "dependencies": { "@reduxjs/toolkit": "^1.9.7", "jwt-decode": "^4.0.0", "lodash": "^4.17.21", "react": "^18.3.1", "react-redux": "^8.1.3", - "terraso-backend": "github:techmatters/terraso-backend#74fc2fc", + "terraso-backend": "github:techmatters/terraso-backend#fac222b", "uuid": "^10.0.0" }, "engines": { diff --git a/dev-client/package.json b/dev-client/package.json index bf2c0efdb3..2b544c4e2e 100644 --- a/dev-client/package.json +++ b/dev-client/package.json @@ -80,7 +80,7 @@ "react-native-svg": "^15.9.0", "react-native-tab-view": "^4.0.1", "reduce-reducers": "^1.0.4", - "terraso-client-shared": "github:techmatters/terraso-client-shared#cdf2161", + "terraso-client-shared": "github:techmatters/terraso-client-shared#ac0867a", "use-debounce": "^10.0.4", "uuid": "^10.0.0", "yup": "^1.4.0" diff --git a/dev-client/src/model/soilId/soilIdFunctions.ts b/dev-client/src/model/soilId/soilIdFunctions.ts index 82c9263414..cd2cf7e644 100644 --- a/dev-client/src/model/soilId/soilIdFunctions.ts +++ b/dev-client/src/model/soilId/soilIdFunctions.ts @@ -20,7 +20,6 @@ import {mhvcToLab} from 'munsell'; import { DataBasedSoilMatch, LabColorInput, - LocationBasedSoilMatch, Maybe, SoilIdInputData, SoilIdInputDepthDependentData, @@ -159,10 +158,15 @@ export const soilIdEntryForStatus = (status: SoilIdStatus): SoilIdEntry => { }; export const soilIdEntryLocationBased = ( - matches: LocationBasedSoilMatch[], + matches: DataBasedSoilMatch[], ): SoilIdEntry => { return { - locationBasedMatches: matches, + locationBasedMatches: matches.map( + ({dataMatch, combinedMatch, locationMatch, ...rest}) => ({ + ...rest, + match: combinedMatch, + }), + ), status: 'ready', }; }; diff --git a/dev-client/src/model/soilId/soilIdSlice.ts b/dev-client/src/model/soilId/soilIdSlice.ts index 3929f17560..02f4ba41d8 100644 --- a/dev-client/src/model/soilId/soilIdSlice.ts +++ b/dev-client/src/model/soilId/soilIdSlice.ts @@ -17,7 +17,11 @@ import {createSlice, Draft, PayloadAction} from '@reduxjs/toolkit'; -import {SoilDataPushFailureReason} from 'terraso-client-shared/graphqlSchema/graphql'; +import { + DataBasedSoilMatchesQuery, + SoilDataPushFailureReason, + SoilIdInputData, +} from 'terraso-client-shared/graphqlSchema/graphql'; import * as soilDataService from 'terraso-client-shared/soilId/soilDataService'; import * as soilIdService from 'terraso-client-shared/soilId/soilIdService'; import { @@ -30,6 +34,7 @@ import { SoilIdKey, } from 'terraso-client-shared/soilId/soilIdTypes'; import {createAsyncThunk} from 'terraso-client-shared/store/utils'; +import {Coords} from 'terraso-client-shared/types'; import * as soilDataActions from 'terraso-mobile-client/model/soilId/actions/soilDataActions'; import { @@ -270,14 +275,19 @@ export const deleteProjectDepthInterval = createAsyncThunk( soilDataService.deleteProjectDepthInterval, ); -export const fetchLocationBasedSoilMatches = createAsyncThunk( - 'soilId/fetchLocationBasedSoilMatches', - soilIdService.fetchLocationBasedSoilMatches, +export const fetchLocationBasedSoilMatches = createAsyncThunk< + DataBasedSoilMatchesQuery['soilId']['dataBasedSoilMatches'], + Coords +>('soilId/fetchLocationBasedSoilMatches', coords => + soilIdService.fetchDataBasedSoilMatches({ + coords, + soilData: {depthDependentData: []}, + }), ); -export const fetchDataBasedSoilMatches = createAsyncThunk( - 'soilId/fetchDataBasedSoilMatches', - soilIdService.fetchDataBasedSoilMatches, -); +export const fetchDataBasedSoilMatches = createAsyncThunk< + DataBasedSoilMatchesQuery['soilId']['dataBasedSoilMatches'], + {coords: Coords; soilData: SoilIdInputData; siteId?: string} +>('soilId/fetchDataBasedSoilMatches', soilIdService.fetchDataBasedSoilMatches); export default soilIdSlice.reducer;