Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: list/rank soil inconsistency workaround #2569

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: _, locationMatch: __, combinedMatch, ...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;
Loading