Skip to content

Commit

Permalink
fix: rework depths menu screen (#2823)
Browse files Browse the repository at this point in the history
* fix: remove radio list label from soil depth preset screen

* fix: remove save button; trigger confirm on radio button
  • Loading branch information
paulschreiber authored Jan 14, 2025
1 parent 2b7f817 commit 2ef717e
Showing 1 changed file with 25 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ import {useTranslation} from 'react-i18next';

import {SoilIdSoilDataDepthIntervalPresetChoices} from 'terraso-client-shared/graphqlSchema/graphql';

import {ContainedButton} from 'terraso-mobile-client/components/buttons/ContainedButton';
import {ConfirmModal} from 'terraso-mobile-client/components/modals/ConfirmModal';
import {useModal} from 'terraso-mobile-client/components/modals/Modal';
import {
Column,
Text,
View,
} from 'terraso-mobile-client/components/NativeBaseAdapters';
import {RadioBlock} from 'terraso-mobile-client/components/RadioBlock';

Expand All @@ -46,44 +44,32 @@ export const EditSiteSoilDepthPreset = ({selected, updateChoice}: Props) => {
return (
<Column space="1px" pb="23px">
<Text variant="body1">{t('soil.soil_preset.info')}</Text>
<RadioBlock
label={t('soil.soil_preset.label')}
labelProps={{variant: 'body1'}}
options={{
NRCS: {text: t('soil.soil_preset.NRCS')},
BLM: {text: t('soil.soil_preset.BLM')},
CUSTOM: {text: t('soil.soil_preset.CUSTOM')},
}}
groupProps={{
name: 'soil-preset',
value: selectedPreset,
onChange: (value: string) =>
updateSelectedPreset(
value as SoilIdSoilDataDepthIntervalPresetChoices,
),
}}
<ConfirmModal
trigger={onOpen => (
<RadioBlock
labelProps={{variant: 'body1'}}
options={{
NRCS: {text: t('soil.soil_preset.NRCS')},
BLM: {text: t('soil.soil_preset.BLM')},
CUSTOM: {text: t('soil.soil_preset.CUSTOM')},
}}
groupProps={{
name: 'soil-preset',
value: selectedPreset,
onChange: (value: string) => {
updateSelectedPreset(
value as SoilIdSoilDataDepthIntervalPresetChoices,
);
onOpen();
},
}}
/>
)}
handleConfirm={onConfirm}
title={t('projects.inputs.depths.confirm_preset.title')}
body={t('projects.inputs.depths.confirm_preset.body')}
actionLabel={t('projects.inputs.depths.confirm_preset.confirm')}
/>
<View alignSelf="flex-end">
<ConfirmModal
trigger={onOpen => (
<ContainedButton
size="lg"
onPress={() => {
if (selectedPreset === selected) {
modalHandle?.onClose();
} else {
onOpen();
}
}}
label={t('general.save')}
/>
)}
handleConfirm={onConfirm}
title={t('projects.inputs.depths.confirm_preset.title')}
body={t('projects.inputs.depths.confirm_preset.body')}
actionLabel={t('projects.inputs.depths.confirm_preset.confirm')}
/>
</View>
</Column>
);
};

0 comments on commit 2ef717e

Please sign in to comment.