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

fix: soil selector warning #1747

Merged
merged 3 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 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 @@ -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#45f880e",
"uuid": "^10.0.0",
"yup": "^1.4.0"
},
Expand Down
67 changes: 67 additions & 0 deletions dev-client/src/screens/SoilScreen/components/DepthEditor.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<Row
backgroundColor="primary.dark"
justifyContent="space-between"
px="12px"
py="8px">
<Heading variant="h6" color="primary.contrast">
{renderDepth(t, interval)}
</Heading>
<RestrictBySiteRole
role={[
{kind: 'project', role: 'MANAGER'},
{kind: 'project', role: 'CONTRIBUTOR'},
{kind: 'site', role: 'OWNER'},
]}>
<EditDepthModal
siteId={siteId}
depthInterval={interval.depthInterval}
requiredInputs={requiredInputs}
mutable={!isFromPreset}
/>
</RestrictBySiteRole>
</Row>
);
};
54 changes: 3 additions & 51 deletions dev-client/src/screens/SoilScreen/components/SoilDepthSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Row
backgroundColor="primary.dark"
justifyContent="space-between"
px="12px"
py="8px">
<Heading variant="h6" color="primary.contrast">
{renderDepth(t, interval)}
</Heading>
<RestrictBySiteRole
role={[
{kind: 'project', role: 'MANAGER'},
{kind: 'project', role: 'CONTRIBUTOR'},
{kind: 'site', role: 'OWNER'},
]}>
<EditDepthModal
siteId={siteId}
depthInterval={interval.depthInterval}
requiredInputs={requiredInputs}
mutable={!isFromPreset}
/>
</RestrictBySiteRole>
</Row>
);
};

type Props = {
siteId: string;
requiredInputs: (typeof soilPitMethods)[number][];
Expand Down
Loading