From dce64d93394e3e96a14cf41cff7e945b73f16784 Mon Sep 17 00:00:00 2001 From: tm-ruxandra Date: Thu, 11 Jul 2024 14:22:16 -0400 Subject: [PATCH] fix: soil selector warning (#1747) * refactor: pull DepthEditor component out of SoilDepthSummary * chore: update client shared dep * chore: update dep after merge --- dev-client/package-lock.json | 4 +- dev-client/package.json | 2 +- .../SoilScreen/components/DepthEditor.tsx | 67 +++++++++++++++++++ .../components/SoilDepthSummary.tsx | 54 +-------------- 4 files changed, 73 insertions(+), 54 deletions(-) create mode 100644 dev-client/src/screens/SoilScreen/components/DepthEditor.tsx diff --git a/dev-client/package-lock.json b/dev-client/package-lock.json index 49b928f49..c0bf8fd28 100644 --- a/dev-client/package-lock.json +++ b/dev-client/package-lock.json @@ -55,7 +55,7 @@ "react-native-screens": "^3.32.0", "react-native-svg": "^15.3.0", "react-native-tab-view": "^3.5.2", - "terraso-client-shared": "github:techmatters/terraso-client-shared#f059d42", + "terraso-client-shared": "github:techmatters/terraso-client-shared#e1b4e4d", "uuid": "^10.0.0", "yup": "^1.4.0" }, @@ -25028,7 +25028,7 @@ }, "node_modules/terraso-client-shared": { "version": "0.1.0", - "resolved": "git+ssh://git@github.com/techmatters/terraso-client-shared.git#f059d421d1067c43c2130ec594294cf397935c23", + "resolved": "git+ssh://git@github.com/techmatters/terraso-client-shared.git#e1b4e4d195f8503c25575e305980547ce6d7a32b", "dependencies": { "@reduxjs/toolkit": "^1.9.7", "jwt-decode": "^4.0.0", diff --git a/dev-client/package.json b/dev-client/package.json index aaeb1e47d..de268ad95 100644 --- a/dev-client/package.json +++ b/dev-client/package.json @@ -64,7 +64,7 @@ "react-native-screens": "^3.32.0", "react-native-svg": "^15.3.0", "react-native-tab-view": "^3.5.2", - "terraso-client-shared": "github:techmatters/terraso-client-shared#f059d42", + "terraso-client-shared": "github:techmatters/terraso-client-shared#e1b4e4d", "uuid": "^10.0.0", "yup": "^1.4.0" }, diff --git a/dev-client/src/screens/SoilScreen/components/DepthEditor.tsx b/dev-client/src/screens/SoilScreen/components/DepthEditor.tsx new file mode 100644 index 000000000..3b5a48e75 --- /dev/null +++ b/dev-client/src/screens/SoilScreen/components/DepthEditor.tsx @@ -0,0 +1,67 @@ +/* + * Copyright © 2024 Technology Matters + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see https://www.gnu.org/licenses/. + */ +import {useTranslation} from 'react-i18next'; + +import {AggregatedInterval} from 'terraso-client-shared/selectors'; +import {soilPitMethods} from 'terraso-client-shared/soilId/soilIdSlice'; + +import { + Heading, + Row, +} from 'terraso-mobile-client/components/NativeBaseAdapters'; +import {RestrictBySiteRole} from 'terraso-mobile-client/components/RestrictByRole'; +import {EditDepthModal} from 'terraso-mobile-client/screens/SoilScreen/components/EditDepthModal'; +import {renderDepth} from 'terraso-mobile-client/screens/SoilScreen/components/RenderValues'; + +export type DepthEditorProps = { + siteId: string; + aggregatedInterval: AggregatedInterval; + requiredInputs: (typeof soilPitMethods)[number][]; +}; + +export const DepthEditor = ({ + siteId, + aggregatedInterval: {isFromPreset, interval}, + requiredInputs, +}: DepthEditorProps) => { + const {t} = useTranslation(); + + return ( + + + {renderDepth(t, interval)} + + + + + + ); +}; diff --git a/dev-client/src/screens/SoilScreen/components/SoilDepthSummary.tsx b/dev-client/src/screens/SoilScreen/components/SoilDepthSummary.tsx index a7c1a387b..11a158778 100644 --- a/dev-client/src/screens/SoilScreen/components/SoilDepthSummary.tsx +++ b/dev-client/src/screens/SoilScreen/components/SoilDepthSummary.tsx @@ -29,60 +29,12 @@ import { } from 'terraso-client-shared/soilId/soilIdSlice'; import {DataInputSummary} from 'terraso-mobile-client/components/DataInputSummary'; -import { - Box, - Column, - Heading, - Row, -} from 'terraso-mobile-client/components/NativeBaseAdapters'; -import {RestrictBySiteRole} from 'terraso-mobile-client/components/RestrictByRole'; +import {Box, Column} from 'terraso-mobile-client/components/NativeBaseAdapters'; import {useNavigation} from 'terraso-mobile-client/navigation/hooks/useNavigation'; -import {EditDepthModal} from 'terraso-mobile-client/screens/SoilScreen/components/EditDepthModal'; -import { - pitMethodSummary, - renderDepth, -} from 'terraso-mobile-client/screens/SoilScreen/components/RenderValues'; +import {DepthEditor} from 'terraso-mobile-client/screens/SoilScreen/components/DepthEditor'; +import {pitMethodSummary} from 'terraso-mobile-client/screens/SoilScreen/components/RenderValues'; import {useSelector} from 'terraso-mobile-client/store'; -type DepthEditorProps = { - siteId: string; - aggregatedInterval: AggregatedInterval; - requiredInputs: (typeof soilPitMethods)[number][]; -}; - -const DepthEditor = ({ - siteId, - aggregatedInterval: {isFromPreset, interval}, - requiredInputs, -}: DepthEditorProps) => { - const {t} = useTranslation(); - - return ( - - - {renderDepth(t, interval)} - - - - - - ); -}; - type Props = { siteId: string; requiredInputs: (typeof soilPitMethods)[number][];