Skip to content

Commit

Permalink
feat: temporary workaround to cover up inconsistency between list/ran…
Browse files Browse the repository at this point in the history
…k soils
  • Loading branch information
shrouxm committed Nov 29, 2024
1 parent e0ecc10 commit bcdc04b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
6 changes: 3 additions & 3 deletions dev-client/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 dev-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"react-native-svg": "^15.9.0",
"react-native-tab-view": "^4.0.4",
"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"
Expand Down
10 changes: 7 additions & 3 deletions dev-client/src/model/soilId/soilIdFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {mhvcToLab} from 'munsell';
import {
DataBasedSoilMatch,
LabColorInput,
LocationBasedSoilMatch,
Maybe,
SoilIdInputData,
SoilIdInputDepthDependentData,
Expand Down Expand Up @@ -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',
};
};
Expand Down
26 changes: 18 additions & 8 deletions dev-client/src/model/soilId/soilIdSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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;

0 comments on commit bcdc04b

Please sign in to comment.